When i make a string in PHP with a special character in it like this:
Code: Select all
$myText = "Hi my name is Nicö";
Hi my name is Nicš
This is weird! How to display it properly?
Moderator: General Moderators
Code: Select all
$myText = "Hi my name is Nicö";
But this is just how it looks in your editor, and doesn't say anything about what byte(s) are actual written in your .php file to represent that ö character.nbarten wrote:$myText = "Hi my name is Nicö";
But how can i get the php url encoding also to work with '%C3%A9' instead of '%8E'?Example: Western browsers send 'é' as '%E9' by default (URL encoding). But when the page is in UTF-8, the browser will first lookup the Unicode multi byte encoding of 'é'. In this case, it are 2 bytes because 'é' lies in UTF code point range 128-256. Those two bytes correspond to à and ©, and will result in '%C3%A9' (URL encoding) in the eventual query string. <form method="post" enctype="application/x-www-form-urlencoded"> is the same as <form method="POST"> and uses the same general principle as GET.
You sure? How do you get this result? Because %C2%8E is utf-8 encoding for the character 'Ž', not 'é'.nbarten wrote:Now my PHP encoding gives: %C2%8E
Code: Select all
$url = '%E9';
$url2 = urlencode(iconv('windows-1252','utf-8',urldecode($url))); // $url2 is now '%C3%A9'
$url3 = urlencode(iconv('utf-8','windows-1252',urldecode($url2))); // $url3 is now '%E9'