views:

225

answers:

1

I want to convert my english alphabets to arabic using JavaScript

Do I need to do some kind Unicode conversion for this? An example would be great.

A: 

Well first make sure the file you are saving is Unicode UTF-8, otherwise the characters get all messed up. Do you mean conversion from english to arabic?

If you are converting letter for letter I would recommend making a function will all arabic unicode characters and english letters.

ie.

function en_to_ar(string) {
    var convert = new Array();
    convert["a"] = "/u...";
    ... divide string into every letter, loop through, output result
}

But watch out, Arabic is tricky. With all the vowel marks and stuff. Remember vowel marks count as another character. Also unicode is multi-byte, so .length on an arabic letter vs an english ascii letter will not be the same.

http://javascript.about.com/library/blunicode.htm

Tom