如何将货币HTML字符串转换为JavaScript中的符号。以下是API的响应。例如,需要像£一样转换£。
你可以在这里查看我的API响应:
> getOptions: {
> "FKP": "Falkland Islands pound (£)",
> "GBP": "Pound sterling (£)",
> "GEL": "Georgian lari (ლ)",
> "GGP": "Guernsey pound (£)",
> }
Please suggest.
https://html-online.com/editor/
Following this link if you are click this link (just paste inside in this link `£` automatically converted pounds Symbol like £ )发布于 2017-08-30 17:31:08
是的,最终我得到了一个绝对的解决方案。就像我刚刚安装了npm install html-entities一样。之后,当我们在像这样的特定位置使用时,两个都会给出这个
const Entities = require('html-entities').AllHtmlEntities;
const entities = new Entities();在此之后,console.log(entities.decode('£'))将获得类似于£的结果输出
发布于 2017-08-29 14:06:11
var currency_symbol={
"FKP": "¤",
"GBP": "£",
"GEL": "₡",
"GGP": "₲",
},
Now get it by--
currency_symbol.FKP
currency_symbol.GBP etc发布于 2017-08-29 14:21:50
在某种上下文中使用该字符串有问题,该上下文可以转义HTML控制字符(例如&),或者不会被解释/显示为HTML内容,因此£字符串实际上就是这样显示的。
一种解决方法是不使用像£这样的超文本标记语言实体,而是使用各种货币符号的实际Unicode字符:
getOptions: {
"FKP": "Falkland Islands pound (\u00A3)",
"GBP": "Pound sterling (\u00A3)",
"GEL": "Georgian lari (\u10DA)",
"GGP": "Guernsey pound (\u00A3)",
}作为参考,另请参阅此other currency symbols的Unicode图表。
https://stackoverflow.com/questions/45931151
复制相似问题