1

I have a text area where user can write his SMS. You all know that There is a different in message length between Arabic and English characters.

I would like to know how to know what is the language the user is writing in Javascript?

Kind Regards,

6
  • 3
    "You all know that There is a different in message length between Arabic and English characters." I didn't know. Thanks for the info. Commented Apr 3, 2012 at 7:39
  • 3
    There are possibilities, such as looking at the returned string and, if it's unicode, determining which plane the majority of the characters in the string come from. You could also look at the accept-language header sent by the client, or by trying to figure out the client's location by tying their IP address to a geographical location. However, those techniques are likely never going to be completely reliable, and you're probably best off just asking the user to specify the language. Commented Apr 3, 2012 at 7:45
  • 1
    Do you want to know the language, or the alphabet? Commented Apr 3, 2012 at 7:51
  • Is the difference because the telephone networks have different limits? Is it a difference because messages are limited in bytes rather than actual characters? Commented Apr 3, 2012 at 8:22
  • @Quentin; the difference because messages are different in bytes, 160 English characters= 1 Message AND 70 Arabic characters=1 Message Commented Apr 3, 2012 at 9:10

1 Answer 1

1

Well a simple solution would be to regex the message for special characters. If your pattern matches the arabic format then you can impose one SMS message length, either leave it with the default size.

EDIT:

And your regex could be like:

/\p{Arabic}/
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.