javascript转义非英语以外的特殊字符
我在转义非英语字符时遇到问题。
例如,
var text1 = "ABC Farmacéutica Corporation".
text1 = escape(text1);
output: ABC%20Farmac%E9utica%20Corporation
但我只想转义除非英语字符(如 é)之外的特殊字符。 我们有什么逻辑可以忽略这些字符吗?
请帮忙,提前致谢。
I have a problem with unescaping non-english characters.
For Example,
var text1 = "ABC Farmacéutica Corporation".
text1 = escape(text1);
output: ABC%20Farmac%E9utica%20Corporation
But I would like to escape only special characters other than non-english characters like é.
Do we have any logic for these characters to be ignored?
Please help, Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
escape 函数返回以 Unicode 格式转义的文本。空格表示为 %20(十六进制)。如果我理解正确的话,你不想转义 é,在这种情况下,只想转义空格字符。我能看到这种情况的唯一方法是,您有一个包含那些您不想转义并引用的非英语字符的表。像这样的事情:
是否有任何特殊原因为什么要选择性地转义字符?
The escape function returns the text escaped in the Unicode format. Space is represented as %20 (hexadecimal). If I understand you correctly you don't want to escape é, in this case, only the space character. The only way I can see this is possible is that you have a table containing those non-english characters that you don't want to be escaped and refer to it. Something like this:
Is there any special reason for why you want to escape characters selectively?