Urdu message sent from sql to mobile handset, is in unreadable format

淺唱寂寞╮ 提交于 2019-12-11 03:51:58

问题


I am assigning Urdu text to a variable in c# and inserting it into database (SendMessages table), it saves Urdu message perfectly without any modification, great but when that message is received in any mobile handset then it appears as ??????????????????????, why ? i checked it with all urdu compatible handsets which receive other urdu messages perfectly but not this one.

Code asp.net:

String MessageLanguage= Convert.ToString(ViewState["LanguageCode"]); //

                        if (MessageLanguage == "ur")
                        {
                            String UrduMsg = ComplaintCode +" "+"اپکی سثیکایت درج کردی گیؑ ھے۔ سثیکایت کوڈ یہ ہے";
                            quebiz.Insert(lblContact.Text, UrduMsg, null, Convert.ToInt32(lblComplainantID.Text), null, null);
                            ViewState["LanguageCode"] = null;

                        }

In simple words, urdu message being passed from C# into sql table is fine and perfect, not problem but after receiving same sms in handset, it doesn't work that way.

why ? help ? I am using asp.net C#.net 4.0 with sql server 2014.


回答1:


According to your comments, you're using varchar to store the message in your database. However, varchar does not support Unicode, which means that anything that's not Latin characters (the characters used by English) does not show properly. Change that to nvarchar, which does support Unicode.




回答2:


An idea could be use varchar in your database and follow the steps

  1. Use base 64 to save the data into data base
  2. Use Encoding.UTF8 to get bytes and convert them to Base64
  3. When fetch data from database use Encoding.UTF8.GetString(Convert.FromBase64String("value") and use this value to display.


来源:https://stackoverflow.com/questions/25720874/urdu-message-sent-from-sql-to-mobile-handset-is-in-unreadable-format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!