How to encode UTF-8 to Unicode escape sequences like “u00C1” using PHP?
I found several posts about the opposite.
At this time, I am using a function containing several replaces like
$str = str_replace("Á","u00C1",$str);.
json_encode can do that for you.
json_encode('Á') will get you
"u00c1", so all you would have to do is strip of the doubles quotes from the beginning and end afterwards.
You can directly use it on text strings that contain such special characters in some places:
echo trim(json_encode('Foo Á Bar'), '"'); // result: Foo u00c1 Bar