How do I print a string in PHP in which all the non-ASCII characters gets converted to their HEX value (eg. 0x02) and displayed? I want users to know that they are entering non-ASCII values. I don't want to strip them. Instead, I would like to display it so that they can edit and correct the mistakes.
I want to allow users to enter standard tab, new lines, etc (maybe upto ASCII 127).
I tried quoted_printable_encode()
but it displays =
as =3D
.
Other non-ASCII characters as =[HEXVAL]
. The equal sign creates confusion.
I tried preg_replace('/[[:^print:]]/', '', $string)
but it ended up removing tabs, new lines, etc.