I want to send sms in Hindi Language from Java based Desktop Software. Below is the code which gets the message from JTextArea and appends the message in a URL. With this code I am able to send SMS in Hindi from Macbook but the same is not working in Windows. While sending sms from windows, the characters are replaced with ?
Below is the code that gets the message from the JTextArea
byte[] utf8Bytes;
utf8Bytes = hindiSMS.getText().getBytes(StandardCharsets.UTF_8);
String hindiMessage = new String(utf8Bytes,StandardCharsets.UTF_8);
hindiMessage.replace(" ", "+");
Util.sendSMS(hindiMessage, hindiMobileNos);
Below is the code that sends the sms
String url="http://sms.sendonlinesms.com/sendsmsv2.asp?user=****&password=*******&sender=*****&text="+message+"&PhoneNumber="+mobilenos+"&unicode=1";
URLEncoder.encode(url,"UTF8");
URL myURL=new URL(url);
URLConnection yc = myURL.openConnection();
Update: I have tried the following code as well
URI uri=null;
try {
uri = new URI(
"http",
"sms.sendonlinesms.com",
"/sendsmsv2.asp",
"user=****&password=******&sender=70025&text="+message+"&PhoneNumber="+mobilenos+"&unicode=1",null);
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
URL myURL=uri.toURL();
URLConnection yc = myURL.openConnection();
But it doesn't make any difference. Working fine on Mac but not on Windows. Using the application on mac, I am able to send sms in hindi, but using the application on windows the hindi characters are replaced by '?'