• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 621
  • Last Modified:

Invalid unicode characters error thrown

i am trying to send sms in hindi language. For that i have to supply unicode character of the hindi message as a message body of the sms which was in string type.
I tried using google translation, i can see the hindi language properly, but while supplying the unicode in the code behind to the sms function, Invalid unicode characters
error comes up.
Is there any method to convert that string into proper unicode character?
Please help.

I am using visual web developer express edition  2008(asp.net with c#)
******************Design Page********************************* 
 
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="cms_test" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
    <title>send hindi sms</title> 
    <script type="text/javascript" src="http://www.google.com/jsapi">   
       </script>            
       <script type="text/javascript"> 
           // Load the Google Transliteration API     
           google.load("elements", "1", { packages: "transliteration" }); 
           function onLoad() { 
               var options = { sourceLanguage: 'en', // or google.elements.transliteration.LanguageCode.ENGLISH, 
                   destinationLanguage: ['hi'], // or [google.elements.transliteration.LanguageCode.HINDI], 
                   shortcutKey: 'ctrl+g', 
                   transliterationEnabled: true 
               };        // Create an instance on TransliterationControl with the required        // options.    
               var control = new google.elements.transliteration.TransliterationControl(options);        // Enable transliteration in the textfields with the given ids. 
 
 
               var ids = ["txtMessageHindi"]; 
               control.makeTransliteratable(ids);  // Show the transliteration control which can be used to toggle between        // English and Hindi.                
           } 
           google.setOnLoadCallback(onLoad);   
      </script>   
</head> 
<body> 
    <form id="form1" runat="server"> 
    <div> 
    <table width="100%" border="0" cellspacing="1" cellpadding="5"> 
        <tr> 
            <td> 
                <b>Sms In Hindi</b> 
            </td> 
        </tr> 
        <tr> 
            <td> 
                &nbsp; 
               
            </td> 
        </tr> 
        
        <tr> 
            <td> 
                <table width="100%" border="0" cellpadding="5" cellspacing="1" id="table14"> 
                    <tr> 
                        <td valign="top"> 
                            <table width="100%" border="0" style="border-collapse: collapse; border: 1px solid #7083e1" 
                                cellpadding="5" cellspacing="1" id="table15"> 
                                
                                <tr> 
                                    <td> 
                                        <table border="0" cellpadding="0" style="border-collapse: collapse" width="100%" 
                                            id="table19"> 
                                            <tr> 
                                                <td> 
                                                    <table width="100%" border="0" cellspacing="1" cellpadding="3" id="table20"> 
                                                     <tr> 
                                                            <td height="20" width="25%"> 
                                                                &nbsp; 
                                                            </td> 
                                                            <td height="20" width="5%"> 
                                                            </td> 
                                                            <td height="20" width="70%"> 
                                                            </td> 
                                                        </tr> 
                                                         
                                                         
                                                       
                                                      <tr> 
                                                            <td height="20" width="25%"> 
                                                             Hindi Message Body <br />[Upto 70 characters] 
                                                            </td> 
                                                            <td height="20" width="5%" align="center"> 
                                                                 
                                                            </td> 
                                                            <td height="20" width="70%"> 
                                                               <asp:TextBox ID="txtMessageHindi"  MaxLength="160" runat="server" Width="350px" Rows="9" TextMode="MultiLine"></asp:TextBox> 
                                                            </td> 
                                                        </tr>  
                                                        <tr> 
                                                            <td height="20" width="25%"> 
                                                                &nbsp; 
                                                            </td> 
                                                            <td height="20" width="5%"> 
                                                            </td> 
                                                            <td height="20" width="70%"> 
                                                            </td> 
                                                        </tr> 
                                                        <tr> 
                                                            <td height="20" width="25%"> 
                                                                 
                                                            </td> 
                                                            <td height="20" width="5%"> 
                                                            </td> 
                                                            <td height="20" width="70%"> 
                                                                <asp:Button ID="btnSave" runat="server" Text="Save" onclick="btnSave_Click"/> 
                                                                    &nbsp;&nbsp; 
                                                                                                                                       
                                                            </td> 
                                                        </tr> 
                                                    </table> 
                                                </td> 
                                            </tr> 
                                        </table> 
                                    </td> 
                                </tr> 
                            </table> 
                        </td> 
                    </tr> 
                </table> 
            </td> 
        </tr> 
         
    </table> 
    </div> 
    </form> 
</body> 
</html> 
 
 
 
******************** code behind ********************** 
 
using System; 
using System.Collections.Generic; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
 
public partial class cms_test : System.Web.UI.Page 
{ 
    protected void Page_Load(object sender, EventArgs e) 
    { 
 
    } 
    protected void btnSave_Click(object sender, EventArgs e) 
    { 
        string messageBody = txtMessageHindi.Text; 
        string result1 = Sendsms.SendSmsToMember("918000765559", messageBody, "OL"); 
   Response.Write(result1);//Invalid unicode characters Message thrown 
    } 
}

Open in new window

0
dotsandcoms
Asked:
dotsandcoms
1 Solution
 
zadeveloperCommented:
Use byte[] instead of string to read and pass your data around
0
 
dotsandcomsAuthor Commented:
Not getting help
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now