I'm trying to use the native2ascii ant task but it seems that is not doing anything. Here's my ant task:
<target name="-pre-init">
<native2ascii src="src/com/bluecubs/xinco/messages" dest="src/com/bluecubs/xinco/messages/test"
includes="**/_*.properties"/>
<copy todir="src/com/bluecubs/xinco/messages">
<fileset dir="src/com/bluecubs/xinco/messages/test"/>
</copy>
<delete dir="src/com/bluecubs/xinco/messages/test" />
</target>
I did the copy part to see if it was an overwriting issue but the files come out exactly the same.
This is the output I get when running the task:
Converting 12 files from Z:\Netbeans\Xinco\2.01.xx\Xinco\src\com\bluecubs\xinco\messages to Z:\Netbeans\Xinco\2.01.xx\Xinco\src\com\bluecubs\xinco\messages\test
Copying 12 files to Z:\Netbeans\Xinco\2.01.xx\Xinco\src\com\bluecubs\xinco\messages
Deleting directory Z:\Netbeans\Xinco\2.01.xx\Xinco\src\com\bluecubs\xinco\messages\test
Edit:
Additional information: OS: Windows 7 (but answer should work on any OD) File encoding: Western (ISO-8859-1) obtained with this article.
Any idea?
It ended being a view issue. Looking the files in a raw editor (i.e. Wordpad) showed that the files were already converted by the task. Viewing them from NetBeans shows them the same.
native2ascii
converts native characters likeáéí
to escaped unicode sequences. It means thatá
will be\u00e1
,é
->\u00e9
andí
->\u00ed
. After runningnative2ascii
your files will be standard ASCII files which are more portable.native2ascii
does not touch the characters which are already in the escaped unicode form. Your properties files are already in escaped unicode form so it does not change anything. For example_XincoMessages_cz.properties
contains this line:It's escaped unicode. The nonescaped unicode form is this:
Wordpad vs. Netbans: When you open the properties files with Wordpad it opens it as a simple text file and shows
\u00e1
as\u00e1
. It does not convert it back toá
. Netbeans does this conversion and you see the 'á' character. Furthermore, it writes it back to the disk as\u00e1
(!) when you save the file. To see the raw files use for example a Total or Double Commander which doesn't do any converting. (Note that Netbeans does this conversion just for properties files.)If you put for example an
á
character to your_XincoMessages_cz.properties
file it will be changed to\u00e1
if your run your ant task. Of course now don't use Netbeans for the editing, a simple notepad will do.Loading properties files in java converts the escaped unicode characters to real unicode characters. An example:
It prints:
The ASCII/escaped unicode form in properites files is usually handled well by java applications. Finally, I think your properties files are good in their current format.