使用 PHP 的 SoapClient 将 UTF-16 字符发送到 WCF 服务
我的 PHP 应用程序正在获取用户输入并将其发送到 WCF Web 服务。 有时,我的用户从 Word 复制并粘贴并将 UTF-16 字符获取到他们的消息中,例如“En Dash”\u2013
发生这种情况时,我会收到以下错误。
PHP 致命错误:SOAP-ERROR:编码: 字符串 '\xe2...' 无效 第 31 行 *** 中的 utf-8 字符串
我尝试将 SoapClient 构造函数的编码选项设置为“UTF-16”。 我的请求似乎有效,但我注意到 xml 标头上的编码仍然设置为 UTF-8。
有任何想法吗?
My PHP application is taking user input and sending it to a WCF Web Service.
Sometimes my users copy and paste from Word and get UTF-16 Characters into their message such as the "En Dash" \u2013
I get the following error when this occurs.
PHP Fatal error: SOAP-ERROR: Encoding:
string '\xe2...' is not a valid
utf-8 string in *** on line 31
I've tried setting the encoding option of the SoapClient constructor to 'UTF-16'.
My request seems to work, but I notice the encoding on the xml header is still set to UTF-8.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
WCF 仅适用于 UTF-8,而 word 默认适用于 UTF-16,这解释了为什么它看起来像 UTF8
尝试使用 mbstring 来纠正问题
WCF works in UTF-8 only and word works in UTF-16 by default which explains why its lookling like UTF8
Try using mbstring to correct the issue