I got this php script:
$str = "ú";
echo $str . ' -> ' . urlencode($str) . "\n" ;
Expected Result:
ú -> %FA
Reference: http://www.w3schools.com/tags/ref_urlencode.asp
Actual Result
ú -> %C3%BA
I got this php script:
$str = "ú";
echo $str . ' -> ' . urlencode($str) . "\n" ;
Expected Result:
ú -> %FA
Reference: http://www.w3schools.com/tags/ref_urlencode.asp
Actual Result
ú -> %C3%BA
You encode the ú as UTF-8 (check the encoding of your example code), so urlencode does correctly encode it as %C3%BA.
You were more or less referring to this:
$str = "\xFA"; # ú in LATIN-1
echo $str . ' -> ' . urlencode($str) . "\n" ;
Which gives you your expected result, regardless how you encode the php-code/-file:
ú -> %FA
Demo, that site is using UTF-8 to store the source-code. If you want the output displayed as LATIN-1, this additional example signals the browser the LATIN-1 charset:
header('Content-Type: text/html; charset=latin-1');
$str = "\xFA"; # ú in LATIN-1
echo $str . ' -> ' . urlencode($str) . "\n" ;
ú- computers differ how any character is represented, depending on the charset encoding. For LATIN-1 it does (%FA), for UTF-8 it does not (%C3%BA).