如何在严格的文档类型中查看HTML页面中的阿拉伯/波斯数字? [英] How can I view Arabic/Persian numbers in a HTML page with strict doctype?
本文介绍了如何在严格的文档类型中查看HTML页面中的阿拉伯/波斯数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个从右到左的HTML页面。当我不使用任何文档类型时,我的数字是阿拉伯语/波斯语,但是当我使用严格模式时,他们转向英语。
<!DOCTYPE html PUBLIC - // W3C // DTD HTML 4.0 Final // EN>
在添加doctype之前:
添加doctype后:
我也将这些元标记添加到我的页面:
< meta http-equiv =Content-Type content =text / html; charset = UTF-8/>
< meta http-equiv =Content-Languagecontent =fa/>
那么如何在严格的doctype页面中查看阿拉伯数字(在IE中,因为Firefox不会显示阿拉伯数字)?
解决方案
这里有一个JavaScript代码,可以将1234字符串转换为1234字符串。 b
$ b
var map =
[
& \#1632;,& \#1633; ,&#1634;,&#1635;,&#1636;,
& \#1637;,& \ #1638;, &安培; \#1639;, &安培; \#1640;, &安培; \#1641;
];
函数getArabicNumbers(str)
{
var newStr =;
str = String(str);
for(i = 0; i {
newStr + = map [parseInt(str.charAt(i))];
}
return newStr;
}
I have an HTML page that is right-to-left. When I don't use any doctype, my numbers are in Arabic/Persian, but when I use strict mode they turn to English.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Final//EN">
Before adding doctype:
After adding doctype:
also I added these meta tags to my page:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Content-Language" content="fa" />
So how can I view Arabic numbers in a page with strict doctype (in IE because Firefox doesn't show Arabic numbers anyway)?
解决方案
here is a little javascript code that converts a 1234 string to ١٢٣٤ string
var map =
[
"&\#1632;","&\#1633;","&\#1634;","&\#1635;","&\#1636;",
"&\#1637;","&\#1638;","&\#1639;","&\#1640;","&\#1641;"
];
function getArabicNumbers(str)
{
var newStr = "";
str = String(str);
for(i=0; i<str.length; i++)
{
newStr += map[parseInt(str.charAt(i))];
}
return newStr;
}
这篇关于如何在严格的文档类型中查看HTML页面中的阿拉伯/波斯数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文