GR problem for Chinese
|
007pig
Joined: 2004-06-28
Posts: 5 |
Posted: Mon, 2004-06-28 19:05
|
|||
|
There's a problem when list albums. The Chinese chars doesn't display correctly. "When saving properties to a stream or loading them from a stream, the ISO 8859-1 character encoding is used. For characters that cannot be directly represented in this encoding, Unicode escapes are used; however, 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. " In J2SDK lib/tools.jar, there's a class sun.tools.native2ascii.Main can convert "GB2312" to "unicode escapes" but i'm not a java master so i don't know how to.
|
||||
| Login or register to post comments |

Posts: 1478
GR 1.4 correctly displays album names if they are encoded using HTML entities. Using HTML entities is the only way people who browse to your Gallery will be able to see the albums correctly without having to explicitly set the codepage in their browsers, anyway.
Recent versions of Gallery automatically use HTML entities for non-ASCII characters when an album is created.
Posts: 5
Which version? Gallery 1 or 2? can i get it from cvs and merge it to Gallery 1.4.3?
Posts: 1478
It's Gallery 1.4.4-beta, which you can get from the nightlies site.
Posts: 5
thank you. i'll have a try.
Posts: 5
I have installed gallery 1.4.4 RC1 and gallery remote 1.4-RC1. The problem still exists?
Posts: 5
Hi, i got it.
Here's how i did:
in GalleryComm2.java, add a new method called getEscapeString():
static String getEscapeString(String str) { if (str == null) { return null; } char[] bys = new char[str.length()]; str.getChars(0, str.length(), bys, 0); StringBuffer ttsb = new StringBuffer(); for (int k = 0; k < bys.length; k++) { switch (bys[k]) { case '\\': case '\'': case '\"': ttsb.append("\\"); ttsb.append( (char) bys[k]); break; case '\r': ttsb.append("\r"); break; case '\n': ttsb.append("\n"); break; case '\t': ttsb.append("\t"); break; default: if (bys[k] < ' ' || bys[k] >= '\200') { //System.out.println("unicode..."); ttsb.append("\\u" /*243*/); String s13 = Integer.toHexString(bys[k]); for (int l = s13.length(); l < 4; l++) { ttsb.append('0'); } ttsb.append(s13); } else { ttsb.append( (char) bys[k]); } } } return ttsb.toString(); }modify requestResponse() method:
From:
p.load(new StringBufferInputStream(response));To:
p.load(new StringBufferInputStream(getEscapeString(response)));And i attached the correct screenshot:
Posts: 1478
I guess that wouldn't hurt, I'll add it to the first betas of GR 1.5. Thanks.