gpt4 book ai didi

javascript - 在javascript中将unicode转换为货币符号

转载 作者:行者123 更新时间:2023-11-28 14:33:38 30 4
gpt4 key购买 nike

我正在 appcelerator 中使用货币符号来在 Android 和 iOS 中构建应用程序。我想让许多参数动态化,因此将此值(u20b9)作为 api 传递给 app.由于某些原因无法像这样传递值(\u20b9),因此不带斜杠传递。

当我使用下面的代码时,它可以正常工作:-

var unicode = '\u20b9';
alert(unicode);

输出:- $

当我使用下面的代码时:-

var unicode = '\\'+'u20b9';
alert(unicode);

输出:-\u20b9

因此,它在各处打印\u20b9,而不是 $,这是我不想要的。

提前致谢。

最佳答案

以下内容对我有用:

console.log(String.fromCharCode(0x20aa)); // ₪ - Israeli Shekel
console.log(String.fromCharCode(0x24)); // $ - US Dollar
console.log(String.fromCharCode(0x20b9)); // ₹ - ???

alert(String.fromCharCode(0x20aa) + "\n" + String.fromCharCode(0x24) + "\n" + String.fromCharCode(0x20b9));

关于javascript - 在javascript中将unicode转换为货币符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50584735/

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