Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

require suggestion - FastSMS encoding problem

 
Bharani kumar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am trying to send SMS with following text. I have used UTF8 as the charset.

KIITOS AREAN MATKAPALVELUIDEN KÄYTÖSTÄ. KEHITÄTHÄN PALVELUAMME KANSSAMME AO. LINKIN KAUTTA:<BR>HTTPS://DIGIUMENTERPRISE.COM/ANSWER?LINK=610-9239P92K&Q50785765=HELAT2266&Q50785766=01039064&Q50785767=8IRZSC



but these characters are not being handled correctly as when they arrive at FastSMS they appear as upside down question marks:



KIITOS AREAN MATKAPALVELUIDEN Kï¿„YTï¿–STï¿„. KEHITï¿„THï¿„N PALVELUAMME KANSSAMME AO. LINKIN


please suggest

 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Who knows what the capabilities are of the gateways an SMS has to travel through? I'd restrict it to ASCII.
 
Rob Spoor
Sheriff
Pie
Posts: 20667
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The 3rd party SMS gateway we use at work is limited to ISO-8859-1, but perhaps FastSMS is a bit more limited. You can then try to send UTF-8 but they will ignore it.

Then again, their API mentions UTF-8 XML documents all the time. Are you sure you are sending proper UTF-8? Can you show us the code that sends these UTF-8 documents to FastSMS? I recently solved a similar bug at work that sent UTF-8 using the system default encoding (Windows-1252).

Oh, and please UseAMeaningfulSubjectLine next time. I've modified it for you this time.
 
Bharani kumar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Thanks for the suggestion.
Please see the following code.


 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So the accented characters are right in the source code - what encoding are you using for the source code? Are you specifying that correctly during compilation?
 
Bharani kumar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using 8-bit encoding scheme(UTF-8) while appending it to the URL and i have developed this in eclipse IDE. so i didn't compile it manually.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see anything in the code to suggest that you're using UTF-8; what do you mean by that? If you didn't specify which encoding the source code is in then it's quite likely that the compiler gets it wrong. You need to find out the source file encoding, and make sure it's specified during compilation. I'm sure the IDE documentation covers that.
 
Rob Spoor
Sheriff
Pie
Posts: 20667
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseCodeTags next time. I've added them for you this time.

Also a note: don't use StringBuffer, use StringBuilder. It doesn't have unnecessary synchronization.


Here you already get conversion problems. The StringBufferInputStream uses the system default encoding. The class is deprecated because of this, and it even mentions this.
Besides, I don't get what you're trying to do here. You take a String, convert it to bytes which you then again convert to a String?


This should be enough if you take the original String. The URLEncoder will take any "weird" characters and transform them into something URLs can understand.


Another potential encoding problem here. Use an InputStreamReader with an explicit encoding instead:
Note that bytesRead, no longer necessary for the first part, gets replaced by charsRead, and buffer turns into a char[].

One more thing. If FastSMS allows it, switch to POST. GET can have limitations on the total URL length. POST does not have this problem.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic