Fix garbled message text: Difference between revisions
Jump to navigation
Jump to search
→string starting from \x symbol
m (Text replacement - "Category:Text file processing" to "Category:String manipulation") |
|||
| Line 212: | Line 212: | ||
for each_unicode_character in hex_notation.decode('utf-8'): | for each_unicode_character in hex_notation.decode('utf-8'): | ||
print(each_unicode_character) | print(each_unicode_character) | ||
</pre> | |||
Using PHP<ref>[https://stackoverflow.com/questions/7320516/how-to-convert-text-to-x-codes php - How to convert text to \x codes? - Stack Overflow]</ref>: [https://www.ideone.com/m58rEZ See it in action] | |||
<pre> | |||
echo preg_replace_callback("/./", function($matched) { | |||
return '\x'.dechex(ord($matched[0])); | |||
}, '🐘'); | |||
# print \xf0\x9f\x90\x98 | |||
</pre> | </pre> | ||