smskannelsoutheast-asian-languages

Sending burmese through Kannel


i am trying to send SMS in burmese from kannel but it does not get in proper format on phone, im getting some unknown symbols or Chinese characters instead can any one help me with this here's my code INFO: the phone is already having burmese language installed...

package com.mms.tools;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;

public class Sendx
{
public static void main(String args[]) 
{
String text = "နိိက္ငိနအထမအ ါါအအနါ ";
StringBuffer myurlx = new StringBuffer();
StringBuffer aResult = new StringBuffer();
try
{
   myurlx.append("http://127.0.0.1:13013/cgi-bin/sendsms?");
   myurlx.append(URLEncoder.encode("username","UTF-   8")).append("=").append(URLEncoder.encode("tester","UTF-8"));
   myurlx.append("&").append(URLEncoder.encode("password","UTF-8")).append("=").append(URLEncoder.encode("foobar","UTF-8"));
   myurlx.append("&").append(URLEncoder.encode("to","UTF-8")).append("=").append(URLEncoder.encode("+919096565288","UTF-8"));

   myurlx.append("&").append(URLEncoder.encode("smsc","UTF-8")).append("=").append(URLEncoder.encode("at","UTF-8"));


   myurlx.append("&").append(URLEncoder.encode("coding","UTF-8")).append("=").append(URLEncoder.encode("2","UTF-8"));
   myurlx.append("&").append(URLEncoder.encode("text","UTF-8")).append("=").append(URLEncoder.encode(text,"UTF-8"));
   myurlx.append("&").append(URLEncoder.encode("dlr-mask","UTF-8")).append("=").append(URLEncoder.encode("31","UTF-8"));
}

catch(UnsupportedEncodingException e)
{
e.printStackTrace();
}
   try
{
       URL url = new URL(myurlx.toString());
       System.out.println("INFO : Opening connection ");
       HttpURLConnection urlconnection = (HttpURLConnection) url.openConnection();
       System.out.println("INFO : Connection openned");
       BufferedReader input = new BufferedReader( new InputStreamReader(urlconnection.getInputStream()));
       String inputLine;

       while ((inputLine = input.readLine()) != null)
           aResult.append(inputLine);
       input.close();
    }
catch(Exception e)
{
       e.printStackTrace();
    }

   System.out.println("response : "+aResult.toString());
   System.out.println("INFO : all sent disconnect.");
}
}

Solution

  • Try adding

       myurlx.append("&").append(URLEncoder.encode("charset","UTF-8")).append("=").append(URLEncoder.encode("utf-8","UTF-8"));
    

    to your code to add a

     charset=utf-8
    

    extra parameter to your url.