I need to convert all English numbers that appear in a given HTML page to Arabic ones (to be independent from the user browser encoding). I prefer to use javascript or it will be great if this can be handled using CSS.
I found some pages doing this but I found that the Arabic letters are added with their ASCII representation in the source code. Does it mean that they are applying some sort of a java script function?
Any clue how can I do something like this?
How about a straight replace function?
String.prototype.toIndiaDigits= function(){
var id= ['۰','۱','۲','۳','۴','۵','۶','۷','۸','۹'];
return this.replace(/[0-9]/g, function(w){
return id[+w]
});
}
// test
var S='The year 2009 has only 365 days';
alert(S.toIndiaDigits());
/* returned value: (String)
The year ۲۰۰۹ has only ۳۶۵ days
*/