1

MS Word 使用 Windows-1252 字符编码集中的字符,这些字符未以 ASCII 或 ISO-8859-1 表示。

// smart single quotes and apostrophe
s = s.replace(/[\u2018|\u2019|\u201A]/g, "\'");
// smart double quotes
s = s.replace(/[\u201C|\u201D|\u201E]/g, "\"");
// ellipsis
s = s.replace(/\u2026/g, "...");
// dashes
s = s.replace(/[\u2013|\u2014]/g, "-");
// circumflex
s = s.replace(/\u02C6/g, "^");
// open angle bracket
s = s.replace(/\u2039/g, "<");
// close angle bracket
s = s.replace(/\u203A/g, ">");
// spaces
s = s.replace(/[\u02DC|\u00A0]/g, " ");

我在编码之前使用了 REPLACE 函数来解决这个问题。但是我找不到 --> 的正确值,它被转换为不同的格式。由于这个问题,我得到了脚本错误并导致异常页面。

4

1 回答 1

0

实际上左右智能双引号将具有十六进制值 93 和 94。因此,请使用这些值而不是它们的 Utf-8 值,例如 201C 或 201D,例如

  str.replaceAll( "[\\u0093|\\u0094]", "\"" )
于 2014-01-07T07:28:32.950 回答