php - UrlEncoding giving different results -
javscript function:
var s="ì"; var e=encodeuricomponent(s); document.write(e);
exspected result: %c3%ac result: %c3%ac
php function:
$s = "ì"; echo $e = urlencode($s);
exspected result: %c3%ac result: %ec
what doing wrong?
your php file encoded in single-byte encoding, iso-8859-1. when type in non-ascii character, use encoding's representation of character. expecting utf-8 (multi-byte) result.
to result, encode php file utf-8 file. usually, ide have option this; in "save as..." dialog.
alternatively, if can't or don't want change file's encoding, can do
echo $e = urlencode(utf8_encode($s));
Comments
Post a Comment