gpt4 book ai didi

html - 如何通过在 html 中设置语言来使浏览器自动格式化数字?

转载 作者:太空宇宙 更新时间:2023-11-03 22:33:37 25 4
gpt4 key购买 nike

是否可以添加一些标签或编写一些 CSS 代码来使浏览器呈现类似这样的 html 代码:

<div lang="fa">1 2 3 4 5 6</div>

为此:

۱ ۲ ۳ ۴ ۵ ۶

?

最佳答案

这里我使用了 Unicode shift,因为任何 Unicode 组中的数字都按照与拉丁组相同的顺序放置(即 [0x0030 ... 0x0039])。因此,例如,对于 Arabic-Indic 组移位是 0x0630。 unicode codepros我希望这是你想要的。

$("[lang='fa']").text(function(i, val) {
return val.replace(/\d/g, function(v) {
return String.fromCharCode(v.charCodeAt(0) + 0x0630);
});
});
div {
font-size: 18px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div lang="fa">0123456789</div>

关于html - 如何通过在 html 中设置语言来使浏览器自动格式化数字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47588688/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com