+2  A: 

Do it serverside with a language you prefer. Java/ECMA script is really a bad place for such operations. It is already a mess with character encoding so do yourself a favour and skip the hassle with content-types and stuff. Send the string as UTF8 (for instance) to your server and do the work there.

jAndy
i can't, it must be with jQuery, all my page is on ajax, and all data is processed by client side. If i do it server side, would be a little nasty -.-
CuSS
What? No, sending SMS from the webpage would be "nasty" as you put it. Use jQuery to submit the textbox **as text** to the server, and have the server send the SMS. Seriously, don't do it from the client.
Neil Barnwell
The SMS text isn't the only thing it sends, it sends the client numbers, etc. the response will create images to dettermine if the sms was sent or not. If the sms has too many chars what do i tell to user? if i put that on server side i need to create another event to call alerts from server on the page...
CuSS
Presumably you're going to be using an authenticated service, which will require credentials or authentication token to be provided in the request. Including this in the JS of the page is going to be a serious problem. You really need to do at least some of the process server-side to alleviate these issues.
ptomli
the authentication is made before the script load. If the user isn't authenticated, he will not load the script. i will edit my question...
CuSS
A: 

What system are you using to send the SMS from jQuery? I suspect it will be via a HTTP request, in which case the service should do encoding for you. In some cases there are characters which are not represented in the GSM character set, and other cases where characters need to be represented as an 'escaped pair' of bytes.

The documentation for the service you're using should be able to inform you of the correct formatting for the SMS body.

For example: http://www.bulksms.com/int/docs/eapi/submission/character_encoding/

Full disclosure: I work for BulkSMS

ptomli
the http request will be sent to my servers, they will be evaluate the client, if he has bills to pay etc, and then if the sms has validated, will send the sms through our api to bulksms servers ;) (i'm your client)
CuSS
Then I suggest your course of action is to filter characters which cannot be sent via standard 7bit messages. You can do this client-side, to help the UI, but you really should also do it server-side. Any characters in the message body which are part of the extended GSM charset will need to be escaped, as per the docs. Otherwise you'll have to send unicode messages, but that means a bit more complication, and reduced message length.
ptomli
can you give me your email contact? does your EAPI have that function?i've edited my question. thanks
CuSS
Send an email to support at bulksms dot com, request it be escalated FAO pault
ptomli
Hi again pault, i've already sent an email...can you respond it please? this issue is urgent... very thank you
CuSS