Skip to content

Instantly share code, notes, and snippets.

@ulisseslima
Last active July 31, 2017 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ulisseslima/d614a31b73947471e04176b0951527bd to your computer and use it in GitHub Desktop.
Save ulisseslima/d614a31b73947471e04176b0951527bd to your computer and use it in GitHub Desktop.
Unicode Espace Generator for Java Properties (Bash wrapper for native2ascii JDK tool)
#!/bin/bash
tmp=tmp-unicode-escape.txt
tmp_out=out-$tmp
text="$1"
if [ ! -n "$text" ]; then
echo "first arg must be the text to escape"
exit 1
fi
echo "$text" > $tmp
native2ascii -encoding utf8 $tmp $tmp_out
cat $tmp_out
rm $tmp $tmp_out
@ulisseslima
Copy link
Author

Example:

user@domain:~$ ./uescape.properties.sh áéíóú
\u00e1\u00e9\u00ed\u00f3\u00fa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment