我可以使用HTML净化器来发现编码问题,而不仅仅是剥离它们吗?


Can I use HTML purifier to find encoding issues instead of just stripping them?

我有一个(大)文本体,我正在努力尝试将它从最初的网络友好格式转换为"稍微"更严格的格式(epub -一些读者对他们接受的HTML非常挑剔)。

HTML净化器可以很好地解决一类问题,我称之为"糟糕的编码"。比如缺少闭括号(这在技术上是合法的HTML)和其他浏览器自动解决的麻烦。

当HTML净化器工作很好是当它遇到编码问题。许多字符被保存在Ӓ格式,是什么(显然?)HTML净化器不关心。也许我需要更好地配置它。另一个问题是我存在的祸根:大引号、破折号等。我已经设法对这些问题做了大量的搜索和替换,但让我担心的是,我可能在某个地方遗漏了一个字符(因为遇到了一个包含重音和坟墓标记的deja vu拼写案例)。

有没有办法让HTML净化器告诉我有这样的字符有问题,而不是默默地剥离它们?我试图通过代码查看,但软件是非常设计的一个不同的用例场景("默默地"处理用户输入,而不是一个程序员做文本主体的大规模转换),我只是没有看到我正在寻找的数据。

我认为这个函数mysql_real_escape_string($text)是为您的问题

$text="It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).";
$main = mysql_real_escape_string($text);
相关文章: