使用JavaScript将转义的html ASCII代码转换为纯文本 [英] Convert escaped html ASCII codes to plain text using JavaScript

查看:218
本文介绍了使用JavaScript将转义的html ASCII代码转换为纯文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望将一串指定ASCII代码的html实体(即:a)转换为它们所代表的ASCII字符(即:a)。我正在使用对象的属性并尝试分配值。例如:

I'm looking to convert a string of html entities specifying ASCII codes (ie: a) to the ASCII characters they represent (ie: a). I'm using a property of an object and trying to assign a value. For instance:

object.Text("");

当我传递的是表示实体的字符串时,我得到相同的字符串。我找不到将实体转换为它们所代表的字符的函数。

When I pass is the string representing the entity, I get the same string back. I can't find the function to convert entities to the characters they represented.

推荐答案

尝试 String.fromCharCode()函数。

alert(String.fromCharCode(97));

正如你所看到的,你将不得不去掉&符号和英镑符号。

As you can see, you'll have to strip out the ampersand and pound sign.

祝你好运......

Best regards...

这篇关于使用JavaScript将转义的html ASCII代码转换为纯文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆