Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a built in python function to escape a string of unicode characters into unicode escape sequences "\uXXXX\uXXXX\uXXXX"?

Tags:

python

unicode

Like repr(), except converting into \uXXXX instead of \x00

*edited title

like image 232
CheapSteaks Avatar asked Dec 30 '25 20:12

CheapSteaks


1 Answers

repr() works fine on Unicode strings. For printable ASCII characters, it will print the character, and for unprintable characters, it will print the Unicode escape sequence.

like image 172
agf Avatar answered Jan 02 '26 10:01

agf



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!