Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » UTF-8 encoding UTF-8 encoding [message #1755160] Tue, 28 February 2017 15:17 Go to next message
Djak Mising name is currently offline Djak Mising nameFriend
Messages: 16
Registered: November 2010
Junior Member
I did a lot of research but I can't find a way to manage the OSGI-INF\l10n .properties files in UTF-8, is there any way to do that in Eclipse E3 RCP application?

For the I use this code that works very well but I didn't manage to do the same for the

		// initialize resource bundle
		NLS.initializeMessages(baseName, clazz);

		// reencode the fields
		final Field[] fieldArray = clazz.getDeclaredFields();
		final int len = fieldArray.length;
		for(int i = 0; i < len; i++) {
			final Field field = (Field) fieldArray[i];
			if(field.getType() == java.lang.String.class) {
				try {
					final String rawValue = (String) field.get(null);
					field.set(null, new String(rawValue.getBytes("ISO-8859-1"), "UTF-8"));
				catch(Exception e) {
				//	e.printStackTrace();

The purpose here is to display the correct UTF-8 strings in the RCP Application but also in the IDE.
Thanks in advance for any advice.
Re: UTF-8 encoding [message #1755890 is a reply to message #1755160] Thu, 09 March 2017 01:56 Go to previous message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 877
Registered: January 2012
Senior Member

I'll just note that the javadoc for Properties.load(InputStream) says that the file format is defined to be in ISO8859-1 with use of Unicode escapes:
     * Reads a property list (key and element pairs) from the input
     * byte stream. The input stream is in a simple line-oriented
     * format as specified in
     * {@link #load( load(Reader)} and is assumed to use
     * the ISO 8859-1 character encoding; that is each byte is one Latin1
     * character. Characters not in Latin1, and certain special characters,
     * are represented in keys and elements using Unicode escapes as defined in
     * section 3.3 of
     * <cite>The Java&trade; Language Specification</cite>.
Previous Topic:Exporting files to other formats
Next Topic:Message Console takes focus away from application
Goto Forum:

Current Time: Mon Nov 30 09:20:39 GMT 2020

Powered by FUDForum. Page generated in 0.01797 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top