尝试从 SVN 日志命令解析 XML 时出错
我正在尝试构建一个简单的下拉列表,它将显示特定文件的修订版本。从选择的选项中,我使用 jQuery 获取该修订版中包含的当前文本并填充文本区域(使用 svn cat)。
我的 HTML 文件中的标头:
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
我的 shell 命令:
svn log --xml "file:///C:/Documents and Settings/username_here/Desktop/svnrepo/Web/trunk/my_file.php"
XML 解析调用:
$xmlData = simplexml_load_string(utf8_decode(trim(shell_exec($cmd))));
此时,我收到此错误:
输入的不是正确的UTF-8,指示 编码!字节:0xE9 0x20 0xE7 0x61
-我正在使用 utf8_decode 函数来帮助正确显示字符。例如,“é”显示为“é” -
如果我将元标记更改为 utf-8,它会正确显示。但是,我需要为每个组织设定规则 ISO-8859-1
-我使用 file:/// 协议调用我的 SVN 存储库作为暂时的临时措施
有趣的是,我的 jQuery 调用只需要一个标头调用它可以正确显示字符(shell_exec(svn cat...)):
header('Content-type: text/html; charset=ISO-8859-1') ;
I'm trying to build a simple drop down that will display the revisions of a specific file. From the option chosen, I use jQuery to fetch the current text contained in that revision and populate a textarea (using svn cat).
The header in my HTML file:
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
My shell command:
svn log --xml "file:///C:/Documents and Settings/username_here/Desktop/svnrepo/Web/trunk/my_file.php"
XML parsing call:
$xmlData = simplexml_load_string(utf8_decode(trim(shell_exec($cmd))));
At this point, I get this error:
Input is not proper UTF-8, indicate
encoding ! Bytes: 0xE9 0x20 0xE7 0x61
-I'm using the utf8_decode function to help display characters properly. For instance, "é" gets displayed as "é"
-If I change the meta tag to utf-8, it displays properly. However, I need to have ISO-8859-1 per organizational set rules
-I'm calling my SVN repo using the file:/// protocol as a temporary measure for the moment
Funny enough, my jQuery call only necessitated a header call for it to display the characters properly (shell_exec(svn cat...)):
header('Content-type: text/html; charset=ISO-8859-1') ;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据评论,我在读取 XML 时删除了 utf8_decode 函数,并在显示文本时应用它。
现在就像一个魅力。
Per the comments, I removed the utf8_decode function when reading in the XML and applied it when displaying the text.
Works like a charm now.