Converting a Word document into usable HTML in PHP(在 PHP 中将 Word 文档转换为可用的 HTML)
问题描述
我有一组 Word 文档,我想使用我编写的 PHP 工具发布这些文档.我将 Word 文档复制并粘贴到文本框中,然后使用 PHP 程序将它们保存到 MySQL 中.我遇到的问题源于 Word 文档具有的所有非标准字符,例如弯引号和省略号 ("...").我目前所做的是用纯文本或 HTML 实体(é 等)手动搜索和替换这些类型的东西(以及外来符号,例如 e-acute) 是否有 PHP 中的函数我可以调用将获取 Word 文档的输出并将所有应为实体的内容转换为实体,并将其他在 Firefox 中无法正确显示的符号转换为可以显示的符号.
I have a set of Word documents which I want to publish using a PHP tool I've written. I copy and paste the Word documents into a text box and then save them into MySQL using the PHP program. The problem I Have arises from all the non-standard characters that Word documents have, like curly quotes and ellipses ("..."). What I do at the moment is manually search and replace these kinds of things (and also foreign symbols such as e-acute) with either plain text or HTML entities (é ; etc) Is there a function in PHP I can call that will take the output of a Word document and convert everything that should be entities into entities, and other symbols that don't display properly in Firefox into symbols that do display.
谢谢!
推荐答案
更好的解决方案是确保您的数据库设置为支持 UTF-8 字符.扩展集中可用的附加字符应涵盖您所谈论的所有非标准"字符.
A better solution would be to ensure that your database is set-up to support UTF-8 characters. The additional characters available in the extended set should cover all the "non-standard" characters that you're talking about.
否则,如果您确实必须将这些字符转换为 HTML 实体,请使用 htmlentities().
Otherwise, if you really must convert these characters into HTML entities, use htmlentities().
这篇关于在 PHP 中将 Word 文档转换为可用的 HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 PHP 中将 Word 文档转换为可用的 HTML
基础教程推荐
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 如何替换eregi() 2022-01-01
