0

Problem with language properties

asked 2009-01-24 09:15:42 +0800

HananW gravatar image HananW
160 2

I am using ZK 3.5.2 and JBoss 4.0.2.

I changed the JBoss command to include: -Dfile.encoding=windows-1255 (for the Hebrew language), unfortunately it did not solve the problem and the language resources was not loaded correctly (it used UTF-8 to parse the properties file).

To solve the problem I modified the Maps class to use the default character set if it did not received any (that is the case when loading language properties - it always pass null to the character set parameter) as followed:

	public final static void load(Map map, InputStream sm, String charset,
	boolean caseInsensitive) throws IOException {
		final PushbackInputStream pis = new PushbackInputStream(sm, 3);
		if (charset == null || charset.startsWith("UTF")) {
			final byte[] ahead = new byte[3];
			int n = pis.read(ahead);
			if (n >= 2
			&& ((ahead[0] == (byte)0xfe && ahead[1] == (byte)0xff)
				|| (ahead[0] == (byte)0xff && ahead[1] == (byte)0xfe))) {
				charset = "UTF-16";
				//don't eat UTF-16 BOM, since Java use it to know endian
			} else if (n == 3 && ahead[0] == (byte)0xef
			&& ahead[1] == (byte)0xbb && ahead[2] == (byte)0xbf) {
				charset = "UTF-8";
				n = 0; //eat UTF-8 BOM since Java won't handle it
			} else if (charset == null) {
				// original line: charset = "UTF-8";
				charset = java.nio.charset.Charset.defaultCharset().displayName();
			}
			if (n > 0)
				pis.unread(ahead, 0, n);
		}

		:
		:
		:
	}

I do not know if this is a bug or there is another way to do it.

Hanan.

delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2009-01-29 16:17:52 +0800

henrichen gravatar image henrichen
3869 2
ZK Team

Please post to ZK Bugs. We will discuss this case there.

link publish delete flag offensive edit

answered 2009-01-29 19:47:46 +0800

HananW gravatar image HananW
160 2

Ok, Done.

link publish delete flag offensive edit

answered 2009-02-20 09:07:42 +0800

RyanWu gravatar image RyanWu
533 2
about.me/flyworld

Hi HananW,
This is the way you use to get the charset,

charset = java.nio.charset.Charset.defaultCharset().displayName();

Obviously you do set the encoding and you can't get it.
So the problem is cause by JBoss' setting and maybe you can find some solution from their forum discussion.

link publish delete flag offensive edit

answered 2009-02-22 23:50:29 +0800

HananW gravatar image HananW
160 2

Hi Ryan,

I do not think the problem in with JBoss, since if you look at my message you will see that only after I Added the code you suggested to a ZK class thing start to work.
So my logic is that if I had to change a ZK class one of two possibilities exists:
1. There is a bug in ZK (and not in JBoss).
2. There is a different way to do what I wanted.

Since I did not see any other way, it seems to me that this is a ZK bug.

Regards,
Hanan.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2009-01-24 09:15:42 +0800

Seen: 173 times

Last updated: Feb 22 '09

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More