Reputation: 529
I have a variable in php and the value is in another language:
שלום לכולם
when I try to get the value back it returns this:
%u05D0%u05D9%u05EA%u05D9
if I set the variable value in english it returns the intended value just fine, but in any other language it will return some weird combination similar to that. can somebody help me? thanks
this is the code
if(isset($_POST['submit'])){
sleep(0.1);
$myfile = fopen('names.txt','a');
fwrite($myfile, $_COOKIE['output']. "\n");
fclose($myfile);
$_COOKIE['output']=null;
}
the variable is output
Upvotes: 1
Views: 100
Reputation: 1492
Those characters are in Unicode and in cookies those are typically stored as encoded one way or another. Usually url-encoded.
For encoding presented in question you may decode it that way:
$encoded = "%u05D0%u05D9%u05EA%u05D9";
$decoded = json_decode("\"".str_replace('%',"\\",$encoded)."\"");
echo $decoded; // should show איתי
Upvotes: 3