简体   繁体   中英

Encoding issue with URLConnection URL containing accented characters

I am using URLConnection to connect with my Apache server to download files.

If I use this url : http://myserver.com/files/ete.ext - it works however if I make http://myserver.com/files /été.ext it doesn't work.

Any help please?

Use this function:

$address = iconv('ISO-8859-1', 'UTF-8', $address);

I hope this will be helpful, if iconv extension is available

I had a similar issue while working with the google maps API. Certain places had accented characters and it didn't work properly. My workaround (it is probably pretty sloppy) was to simply replace all of the accented characters with non-accented ones.

I simply called the replaceAll function for all of my strings and got rid of all of the invalid characters.

I hope this helps

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