Automate conversion of special chars to utf-8
I have a properties file in this format
attribute1=ó
The problem is I need to convert ó to utf-8 so it can be displayed by java s开发者_StackOverflowo ó becomes \u00F3
My properties file becomes -
attribute1=\u00F3
Is there a way to automate this using Java ? In theory to cycle through every character in the file and if a character contains ó (or any non standard ascii character) convert it to its unicode value ?
Or maybe there is a tool out there that already handles this type of conversion ?
Thanks
JDK comes bundled with a tool called native2ascii. You will give your properties file as input to the tool and it will perform all the conversion/escaping for you. Look here for the usage.
However the best option in my opinion is to use the tools like JRC editor. You enter the text in native language and when you save the tool automatically escapes the characters where required
精彩评论