send arabic SMS on mobile in java -


in application there both arabic , english language suport facing problem when mobile receive arabic sms displaied ??? ???? (question marks) knowing monbile using testing supports arabic , arabic in application working fine problem when arabic sms received mobile.

string ff = new string(smscontent.getbytes("utf-8"), "utf-8");             stringwriter stringbuffer = new stringwriter();             printwriter pout = new printwriter(stringbuffer);             pout.print("<?xml version=\"1.0\" encoding=\"utf-8\"?>");         pout.print("<!doctype message system \"http://127.0.0.1/psms/dtd/messagev12.dtd\" >");         pout.print("<message ver=\"1.2\"><user username=\""+username+"\" password=\""+password+"\"/>");         pout.print("<sms udh=\"0\" coding=\"1\" text=\""+ff+"\" property=\"0\" id=\"2\">");         pout.print("<address from=\""+fromno+"\" to=\""+tono+"\" seq=\"1\" tag=\"\" />");         pout.print("</sms>");         pout.print("</message>");          pout.flush();         pout.close();   url url = new url("url");          httpurlconnection connection = (httpurlconnection)url.openconnection();         connection.setdooutput(true);          bufferedwriter out = new bufferedwriter(new outputstreamwriter(connection.getoutputstream()));          out.write("data="+message+"&action=send");         out.flush(); 

sms in english working file in application.

first, new string(smscontent.getbytes("utf-8"), "utf-8") redundant roundtrip, equivalent smscontent. first encode string bytes via utf-8, , decode bytes again.

second, method of puzzling xml broken. can't concatenate strings , hope end well-formed xml. example think happens if tries send "? use xml library.

third, you're implicitly using platform default encoding outputstreamwriter instead of explicitly specifying one, means code works on machines randomly happen have correct encoding default. i'm guessing yours not.

fourth, method of puzzling post parameters broken. haven't specified variable message is. i'm guessing it's complete xml document, you're trying send post parameter kind of http service, in case needs escaped/url-encoded. example, happens if tries send message &data=<whatever>&? please clarify.

see using java.net.urlconnection fire , handle http requests

fifth, since you're sending http service, there's documentation service encoding send or how specify it, possibly http header (probably "content-type: application/x-www-form-urlencoded; charset=utf-8"?). point documentation if can't figure out yourself.

edit: found documentation: http://www.google.se/search?q=valuefirst+pace

it pretty states need url encode xml document, that's you're missing, in case encoding outputstreamwriter won't matter long it's ascii-compatible.

however, documentation not specify character encoding use url-encoding, pretty weak. utf-8 though.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -