Strophe字符编码问题 [英] Strophe character encoding issue
问题描述
我正在使用XMPP客户端,并且 Strophe (javascript版)发送/接收邮件时遇到问题。
I am working on an XMPP client and having an issue with messages being sent/received by Strophe (javascript version).
问题是包含特殊字符的邮件。例如,如果我发送:
The issue is messages that contain "special" characters. For instance, if I send:
我在这里。
I'm here.
外部客户端(即iChat)将显示
An external client (i.e. iChat) will display
I' m here。
I'm here.
strophe客户端根本不显示任何内容。
A strophe client doesn't display anything at all.
如果我从iChat发送相同的消息对于strophe客户端,它显示正确。
If I send that same message from iChat to the strophe client, it displays properly.
这是我能提出的最基本的示例代码:
Here is the most basic sample code I could come up with:
<html>
<head>
<script type='text/javascript' src='strophe.min.js'></script>
<script type='text/javascript'>
function onConnect(status) {
if (status == Strophe.Status.CONNECTED) {
var message = $msg({to: CONTACT_JID, from: JID, type: 'chat'}).c('body').t("I'm here."); ;
connection.send(message.tree());
}
}
var connection = new Strophe.Connection('http://bosh.metajack.im:5280/xmpp-httpbind');
connection.connect(JID, PASS, onConnect);
</script>
</head>
<body></body>
</html>
提前感谢您的帮助。
编辑:
出站,似乎Strophe是双重编码。当我输入
Outbound, it seems Strophe is double encoding. When I type
我
I'm
它正在发送
<body>I&apos;m</body>
入站,似乎没有正确处理CDATA。任何指导或想法都表示赞赏。
Inbound, it appears to not be handling CDATA properly. Any guidance or ideas are appreciated.
推荐答案
好的,基于
https://github.com/metajack/strophejs/issues/54
https://github.com/metajack/strophejs / pull / 59
你应该删除文本节点的转义。打开非最小化版本的strophe.js文件和注释行#846
you should remove escaping of the text node. Open non-minimized version of strophe.js file and comment line #846
//text = Strophe.xmlescape(text);
这篇关于Strophe字符编码问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!