You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "daniel.green" <oc...@gmail.com> on 2009/07/20 19:43:14 UTC

Converting .properties to UTF8

Upon the packaging of my war, I want to convert all .properties files to
utf8. Can I do this with straight maven or will I need to run an ant task OR
write my own plugin?

Thank you for your time,
Daniel.
-- 
View this message in context: http://www.nabble.com/Converting-.properties-to-UTF8-tp24574361p24574361.html
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Converting .properties to UTF8

Posted by "daniel.green" <oc...@gmail.com>.

Thomas Scheffler wrote:
> 
> If your .properties files should be read by the java.util.Properties class 
> please keep in mind that they HAVE to be encoded in "ISO 8859-1" a.k.a. 
> "latin1".
> 

Currently my native2ascii goal is configured:

      <plugin>
	    <groupId>org.codehaus.mojo</groupId>
	    <artifactId>native2ascii-maven-plugin</artifactId>
	    <executions>
	      <execution>
	        <goals>
	          <goal>native2ascii</goal>
	        </goals>
	        <!-- specific configurations -->
	        <configuration>
	          <encoding>UTF8</encoding>
	          <src>${basedir}/resources</src>
	          <dest>target/classes</dest>
	          <includes>**/*.properties</includes>
	        </configuration>
	      </execution>
	    </executions>
      </plugin>

Does this mean I need to break away from UTF8 and set the encoding value to
something else? Am I just missing the point?


Thomas Scheffler wrote:
> 
> Am Montag, 20. Juli 2009 19:43:14 schrieb daniel.green:
>> Upon the packaging of my war, I want to convert all .properties files to
>> utf8. Can I do this with straight maven or will I need to run an ant task
>> OR write my own plugin?
> 
> If your .properties files should be read by the java.util.Properties class 
> please keep in mind that they HAVE to be encoded in "ISO 8859-1" a.k.a. 
> "latin1".
> 
> see http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html
> 
> "The load and store methods load and store properties in a simple line-
> oriented format specified below. This format uses the ISO 8859-1 character 
> encoding. Characters that cannot be directly represented in this encoding
> can 
> be written using Unicode escapes  ; only a single 'u' character is allowed
> in 
> an escape sequence. The native2ascii tool can be used to convert property
> files 
> to and from other character encodings."
> 
> regards
> 
> Thomas
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Converting-.properties-to-UTF8-tp24574361p24576009.html
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Converting .properties to UTF8

Posted by Jörg Schaible <jo...@gmx.de>.
Thomas Scheffler wrote:

> Am Montag, 20. Juli 2009 19:43:14 schrieb daniel.green:
>> Upon the packaging of my war, I want to convert all .properties files to
>> utf8. Can I do this with straight maven or will I need to run an ant task
>> OR write my own plugin?
> 
> If your .properties files should be read by the java.util.Properties class
> please keep in mind that they HAVE to be encoded in "ISO 8859-1" a.k.a.
> "latin1".
> 
> see http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html
> 
> "The load and store methods load and store properties in a simple line-
> oriented format specified below. This format uses the ISO 8859-1 character
> encoding. Characters that cannot be directly represented in this encoding
> can
> be written using Unicode escapes  ; only a single 'u' character is allowed
> in an escape sequence. The native2ascii tool can be used to convert
> property files to and from other character encodings."

With JDK 6 this has changed, you may also use different encodings. However,
keeping .property files in ISO-8859-1 is good practice and I am not
astonished, that some tools take this for granted.

- Jörg


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Converting .properties to UTF8

Posted by Thomas Scheffler <th...@uni-jena.de>.
Am Montag, 20. Juli 2009 19:43:14 schrieb daniel.green:
> Upon the packaging of my war, I want to convert all .properties files to
> utf8. Can I do this with straight maven or will I need to run an ant task
> OR write my own plugin?

If your .properties files should be read by the java.util.Properties class 
please keep in mind that they HAVE to be encoded in "ISO 8859-1" a.k.a. 
"latin1".

see http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html

"The load and store methods load and store properties in a simple line-
oriented format specified below. This format uses the ISO 8859-1 character 
encoding. Characters that cannot be directly represented in this encoding can 
be written using Unicode escapes  ; only a single 'u' character is allowed in 
an escape sequence. The native2ascii tool can be used to convert property files 
to and from other character encodings."

regards

Thomas

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Converting .properties to UTF8

Posted by Barrie Treloar <ba...@gmail.com>.
On Tue, Jul 21, 2009 at 3:36 AM, daniel.green<oc...@gmail.com> wrote:
>
>> what is your original encoding? why not use UTF-8 directly when editing
>> files?
>>
> We want to go from native to UTF-8. We can't develop in UTF-8 directly due
> to various bugs we've run into with Eclipse (everyone uses it but me) and
> some of our other tools. Before we were using some ant task. I'd like to
> keep with pure maven, though.

If there is no maven plugin just use antrun
(http://maven.apache.org/plugins/maven-antrun-plugin/)

Just bind to the phase you want your ant task to run when specifying
the ant task in your pom.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Converting .properties to UTF8

Posted by "daniel.green" <oc...@gmail.com>.


> what is your original encoding? why not use UTF-8 directly when editing 
> files?
> 
We want to go from native to UTF-8. We can't develop in UTF-8 directly due
to various bugs we've run into with Eclipse (everyone uses it but me) and
some of our other tools. Before we were using some ant task. I'd like to
keep with pure maven, though.


Manos Batsis wrote:
> 
> daniel.green wrote:
>> Upon the packaging of my war, I want to convert all .properties files to
>> utf8. Can I do this with straight maven or will I need to run an ant task
>> OR
>> write my own plugin?
> 
> what is your original encoding? why not use UTF-8 directly when editing 
> files?
> 
> We usually want exactly the opposite, i.e. write our .property files 
> using UTF-8 and in our native language, then use native2ascii executable 
> from the JDK (think there is a maven plugin for that and an ant task is 
> certainly available) to convert the files in ascii to ensure proper 
> interpretation of prop values.
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Converting-.properties-to-UTF8-tp24574361p24574695.html
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Converting .properties to UTF8

Posted by Manos Batsis <ma...@geekologue.com>.
daniel.green wrote:
> Upon the packaging of my war, I want to convert all .properties files to
> utf8. Can I do this with straight maven or will I need to run an ant task OR
> write my own plugin?

what is your original encoding? why not use UTF-8 directly when editing 
files?

We usually want exactly the opposite, i.e. write our .property files 
using UTF-8 and in our native language, then use native2ascii executable 
from the JDK (think there is a maven plugin for that and an ant task is 
certainly available) to convert the files in ascii to ensure proper 
interpretation of prop values.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org