php soap 请求中的特殊字符错误地显示在 xml 输出包中

发布于 2024-09-08 09:07:34 字数 787 浏览 4 评论 0原文

我使用的网络服务在我的请求中包含 ¥ 符号 (chr 0165)。我已将我的肥皂客户端上的编码设置为:

$soap = new MySoapClient('address.wsdl', array('trace' => 1, 'encoding'=>'ISO-8859-1'));

但是,当我查看即将发出的肥皂包时,“¥”更改为“Â¥”,

我不擅长编码,但我尝试了许多不同的组合,使用 UTF8-ENCODE 等,但无济于事...... .我只是希望我的出站肥皂包为字符串变量中的每个“¥”显示“¥”。

更新:

我一定仍然做错了什么......当我添加 utf8_decode("my string with ¥") 时,我将编码保留为所述:

$soap = new MySoapClient('address.wsdl', array('trace ' => 1, '编码'=>'ISO-8859-1'));

我仍然在出站肥皂包中得到“我的字符串与 ¥”作为参数。

如果我省略编码部分:

$soap = new MySoapClient('address.wsdl', array('trace' => 1, 'encoding'=>'ISO-8859-1'));

与 utf8_decode("my string with ¥") 结合使用,我收到以下肥皂错误:

SOAP-ERROR: Encoding: string "my string with ¥" is not a valid utf-8 string.....

有什么建议吗?

I'm using a webservice that in my request includes a ¥ symbol (chr 0165). I have set the encoding on my soap client to:

$soap = new MySoapClient('address.wsdl',
array('trace' => 1, 'encoding'=>'ISO-8859-1'));

But when I look at my outgoing soap package the "¥" is changed to "Â¥"

I'm not good at encoding but I've tried a number of different combinations, using UTF8-ENCODE etc, to no avail....I just want my outbound soap package to show "¥" for every "¥" in my string variable.

Update:

I must still be doing something wrong...when I add the utf8_decode("my string with ¥"), and I leave the encoding as stated:

$soap = new MySoapClient('address.wsdl', array('trace' => 1, 'encoding'=>'ISO-8859-1'));

I still get the "my string with ¥" as parameter in my outbound soap packet.

if i leave out the encoding part in:

$soap = new MySoapClient('address.wsdl', array('trace' => 1, 'encoding'=>'ISO-8859-1'));

combined with the utf8_decode("my string with ¥") I get the following soap error:

SOAP-ERROR: Encoding: string "my string with ¥" is not a valid utf-8 string.....

Any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

嗳卜坏 2024-09-15 09:07:34

您正在输入 UTF-8 编码的 YEN SIGN 但告诉编码为 ISO-8859-1 的服务。

在 UTF-8 中,该字符被编码为两个字节:0xC20xA5

在 ISO-8859-1 中,这两个字节解码为两个单独的字符,带引号的拉丁文大写字母 A日元符号分别。

要解决此问题,请尝试将 utf8_decode 应用于该值,然后再在 SOAP 调用中使用该值。

You are feeding a UTF-8 encoded YEN SIGN but telling the service that its encoded as ISO-8859-1.

In UTF-8, that character is encoded into two bytes: 0xC2 and 0xA5.

In ISO-8859-1, those two bytes are decoded into two separate characters, LATIN CAPITAL LETTER A WITH CIRCUMFLEX and YEN SIGN respectively.

To fix this, try applying utf8_decode to the value before using it in the SOAP call.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文