如何在具有严格文档类型的 HTML 页面中查看阿拉伯/波斯数字? [英] How can I view Arabic/Persian numbers in a HTML page with strict doctype?
本文介绍了如何在具有严格文档类型的 HTML 页面中查看阿拉伯/波斯数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个从右到左的 HTML 页面.当我不使用任何文档类型时,我的数字是阿拉伯语/波斯语,但当我使用严格模式时,它们会变成英语.
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">
在添加文档类型之前:
添加文档类型后:
我也将这些元标记添加到我的页面:
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" />
那么如何在具有严格文档类型的页面中查看阿拉伯数字(在 IE 中,因为 Firefox 无论如何都不显示阿拉伯数字)?
So how can I view Arabic numbers in a page with strict doctype (in IE because Firefox doesn't show Arabic numbers anyway)?
推荐答案
这里有一段 javascript 代码,可以将 1234 字符串转换为 ١٢٣٤ 字符串
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屋!
查看全文