克服PHP,SoapServer,UTF-8和非英文字符的编码问题? [英] Overcome Encoding Problems with PHP, SoapServer, UTF-8, and non English Characters?
问题描述
我在使用SoapServer + UTF-8时很难让PHP玩得很好。任何时候任何人发送一个非英文字符(即有趣的报价,重音字符等)的肥皂请求,SoapServer会抛出一个异常说坏请求。我尝试使用utf8_decode解码请求,甚至HTML特殊字符编码文本。没有什么可以为我工作。
I'm having problems getting PHP to play nicely with SoapServer + UTF-8. Anytime anyone sends a Soap Request with non english characters (i.e. funny quotes, accented characters, etc) the SoapServer throws an exception saying "Bad Request." I've tried decoding the request with utf8_decode and even HTML Special Characters encoded the text. Nothing is working for me.
我正在寻找一个正确的方向,因为我现在迷路了。
I'm looking for a point in the right direction because I'm lost at the moment.
推荐答案
确保 SoapServer 和 SoapClient 使用UTF-8初始化编码:
make sure both SoapServer and SoapClient are initialized with UTF-8 encoding:
$client = new SoapClient("some.wsdl", array('encoding'=>'UTF-8'));
$server = new SoapServer("some.wsdl", array('encoding'=>'UTF-8'));
将请求的XML与有趣的报价,重音字符等验证?
does the XML of the requests with the "funny quotes, accented characters, etc." validate?
这篇关于克服PHP,SoapServer,UTF-8和非英文字符的编码问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!