简体   繁体   中英

PHP CURL passing UTF-8 characters in the URL

When I send a URL which contains UTF-8 characters é and ú, to name a few, the characters are encoded with the PHP function rawurlencode. Once I have my URL generated it is passed off to a CURL request to a Java web service which returns XML data.

Example encoding of the word Chébé is sent the web service as Ch%C3%A9b%C3%A9 which is standard form from what I can tell. I have also tried htmlentities function to convert the string to an entity, then encode the string with rawurlencode.

The item names within the example that the query it is matching against is in entity form for obvious XML reasons.

My question is the web service seems to fail with a 500 Internal error when making a request. All other strings are fine. It is only affected by UTF-8 characters. When I pass the URL within my browser in entity form like Chébé the service responds with results, but when I pass in my browser URL encoded form it fails as well. Am I missing something here?

Google encodes it in the same way q=Ch%C3%A9b%C3%A9 so... it's correct. What are you doing in the handler? Base64 encode it if all else fails assuming you control the handler service too...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM