使用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...