problem of resource bundle getString
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   tof_tof
Posted On:   Wednesday, June 30, 2004 05:22 AM

hello ! i've got a problem maybe you can help me I have a file.properties in wich several message are written like: 100=the message i use a resource bundle to get the msg corrresponding to correct number BUT the problem is that those messages are in slovak... and when i use the resourceBundle method getString, the String i obtain isnt the same as in the file due to encoding.. i dont know how to solve this problem ... there is no method like : myResourceBundle.getString(String s, charset c) (as the constructor for a String where you can specify which charset use to encode the String) plz help ! :) btw : this kind of solution doesnt work :/ ResourceBund   More>>

hello !
i've got a problem maybe you can help me

I have a file.properties in wich several message are written like:
100=the message
i use a resource bundle to get the msg corrresponding to correct number
BUT the problem is that those messages are in slovak...
and when i use the resourceBundle method getString, the String i obtain isnt the same as in the file due to encoding..

i dont know how to solve this problem ... there is no method like : myResourceBundle.getString(String s, charset c)
(as the constructor for a String where you can specify which charset use to encode the String)
plz help ! :)

btw : this kind of solution doesnt work :/

			
ResourceBundle rb=....;
String output=rb.getString("xxx");
try{
byte[] btmp=output.getBytes("Cp1250");
output=new String(btmp,"newencoding");
}catch(Exception e){
...........
}

Cp1250==windows1250==the encoding for slovak.    <<Less

Re: problem of resource bundle getString

Posted By:   Stephen_Ostermiller  
Posted On:   Sunday, July 18, 2004 03:05 AM

You may want to use a specially designed editor such as Attesoro to save your properties files. Attesoro will allow you to enter Slovak text, but it will save any special characters that are not Latin1 in the escaped format expected by Java properties.

Re: problem of resource bundle getString

Posted By:   Sean_Owen  
Posted On:   Wednesday, June 30, 2004 08:01 AM

The problem occurs earlier, when you load the ResourceBundle. It is not interpreting the bytes of your properties file as you expect.



Actually, the properties file must use the ISO-8859-1 encoding. You can specify other characters with escape sequences as described here: Properties.load().



It may be difficult to re-write your file this way. In that case, write your own ResourceBundle implementation which reads your file correctly, using a BufferedReader and FileReader that uses the Cp1250 encoding.

About | Sitemap | Contact