Send SMS in Hindi Using API

By | September 1, 2016

Send Hindi SMS using API is not that easy as it look like. While working on a project i have to send Hindi SMS and when i write hindi in message and send it to the mobile. It shows me ?????????????? ???????? ????? like this. So i figured out if we use unicode to send the message than we can send the SMS in Hindi or other language. This tutorial is about to send SMS in Hindi.



In this tutorial we are using the Bulk SMS API form Simply IT Solutions Pvt Ltd. They are providing fast and perfect delivery.

So here is the magical function to change your message to the UNICODE message.

Above line will change the message to the Unicode By using the below function.

After change the SMS to Unicode it will look like a list of many numbers. Now next part is to send the sms. As i told you earlier that we are using an API so we create a function and passing mobile no and message to that function.



It will send the SMS in Hindi. Hope you like it if you have any advice or comment than please write in the comment box.

 

5 thoughts on “Send SMS in Hindi Using API

  1. Sanjeet Shukla

    I used the code which is given above, but i m getting unicode number instead of hindi msg

    Reply
    1. Vivek Moyal Post author

      For using the unicode message your provider should provide you the Unicode message method in your sms API

      Reply
  2. N Mathur

    Thanks .. this article is very useful .. I am a C# developer and implemented your logic in my code .. it worked 🙂 .. Here is the code.. hope this may help others ..

    public string Utf8ToUnicode(string str)
    {
    var unicode = new List();
    var values = new List();
    var lookingFor = 1;
    var ascii = Encoding.UTF8.GetBytes(str);

    for (var i = 0; i < ascii.Length; i++)
    {
    var thisValue = ascii[i];
    if(thisValue == 32)
    {
    unicode.Add("%20");
    }
    else
    if (thisValue < 128)
    {
    var uniStr = ConvertToHex(thisValue);
    unicode.Add((uniStr.Length == 1) ? "%u000" + uniStr : "%u00" + uniStr);
    }
    else
    {
    if (values.Count == 0)
    lookingFor = (thisValue < 224) ? 2 : 3;
    values.Add(thisValue);
    if (values.Count == lookingFor)
    {
    var number = (lookingFor == 3) ?
    ((values[0] % 16) * 4096) + ((values[1] % 64) * 64) + (values[2] % 64) :
    ((values[0] % 32) * 64) + (values[1] % 64
    );
    var uniStr = number.ToString("X");
    unicode.Add((uniStr.Length == 3) ? "%u0" + uniStr : "%u" + uniStr);
    values = new List();
    lookingFor = 1;
    } // if
    } // if
    }
    return string.Join(“”, unicode.ToArray());
    }

    Reply
    1. Vivek Moyal Post author

      Thank You very much for your kind support. It will be really helpful for other’s.

      Reply
  3. Noor

    Sir am creating a mock test portal for SSC and given the questions in English only but there are so many students who prefer Hindi instead of english and I don’t want to re-type the all questions and options in Hindi, is there any way to display all English typed along with Hindi translation without handling it twice?

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.