AJAX 请求中 Microsoft Word 字符的编码问题

发布于 2024-08-26 06:07:09 字数 435 浏览 4 评论 0原文

我正在编写一个函数,将 MS Word 样式的文本转换为 Adob​​e InDesign 格式的文本(它使用一种 XML 来指示样式)。文本被粘贴到 TinyMCE 富文本编辑器中,然后将 HTML 格式的代码发送到 php 函数。

我尝试过这个函数来清理代码,一旦它到达我的转换代码:

$text = iconv("windows-1250", "UTF-8", $html);

当我使用任何“特殊”类型的字符时,事情就会出错。 £ 符号、é(或任何其他重音符号)和各种“卷曲”撇号/引号似乎会破坏事物。例如,如果我尝试转换 £ 符号,代码会返回 \u0141,但当函数执行时,屏幕上会显示 Ł 符号返回。

有人知道我能做些什么来防止Word的奇怪字符破坏我正在做的一切吗?

I'm writing a function to convert MS Word-styled text into Adobe InDesign-formatted text (it uses a kind of XML to indicate styling). The text is pasted into a TinyMCE rich text editor, which then sends the HTML-formatted code to a php function.

I've tried this function to clean up the code once it reaches my conversion code:

$text = iconv("windows-1250", "UTF-8", $html);

When I use any 'special' kind of characters, things go wrong. £ signs, é (or any other accents), and a variety of 'curly' apostrophes/quote marks seem to break things. For example, if I try to convert a £ sign, the code returns \u0141, but I get the Ł symbol displayed onscreen when the function returns.

Does anybody know what I can do to prevent Word's weird characters breaking everything I'm doing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

芯好空 2024-09-02 06:07:09

我似乎已经解决了这个问题。我使用 escape() 传递值,但将其替换为 encodeURIComponent() (并删除了我的中的 iconv() 调用) php 代码),这似乎已经修复了它。

I seem to have fixed this. I was using escape() to pass the values, but replaced this with encodeURIComponent() instead (and removed the iconv() call in my php code), which seems to have fixed it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文