I know normally one could use rawurlencode() or just urlencode() but alas, these are not working for me.
Basically, I have a string that is UTF-8 encoded with the fancy characters like so:
[text]Gävle[/text]
Now, I need to convert this string to (I don't know the encoding name) look like this:
[text]G%E4vle[/text]
rawurlencode and urlencode both are not encoding the ä at all. How can I do this?
Edit
Just to clarify, it seams that something is working but just not well. For example, I have the string:
[text]Värtavägen 25, Stockholm, Stockholm län, 11553, Sverige[/text]
if I use urlencode() and just print that out to the browser, I get:
[text]V%C3%A4rtav%C3%A4gen+25%2C+Stockholm%2C+Stockholm+l%C3%A4n%2C+11553%2C+Sverige[/text]
which is correct. The problem though is that as soon as I put that into a link, it removes the %C3 type characters (ä) and replaces them with their original ä insanity. I literally have the link:
[text]http://maps.google.se/maps?q=V%C3%A4rta ... -1&iwloc=A[/text]
and as soon as I put this in an address bar, it gets converted to the actual characters which are invalid in a URL. How can I stop this from happening?
Sidenote: I suppose this isn't a PHP question anymore so this post can be moved
Encode UTF-8 for URLs
Moderator: General Moderators
Re: Encode UTF-8 for URLs
Google maps is using the "iso-8859-1" as the charset. If you change it to "ie=utf-8" google properly displays the location.
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
Re: Encode UTF-8 for URLs
Ha, I had no idea. Thanks a milliontr0gd0rr wrote:Google maps is using the "iso-8859-1" as the charset. If you change it to "ie=utf-8" google properly displays the location.