From: Dennis <att...@se...> - 2004-10-02 09:30:06
|
Greeting.=20 I apologize for my poor english,=20 and please tell me which list should I mail if I mail to worng list. I always use chinese title for my albums, and there are no problems when = I use zh_TW language pack except gallery remote client.=20 I found a chinese problem in gallery remote (1.4.2), I cann't get = correct chinese album title in album tree. So, I downloaded the gallery remote source code from cvs and tracked the = source code , then I found why my chinese title is error. In the gallery remote com.gallery.GalleryRemote.GalleryComm2.java line = 1353. Source code try to load response(a String) in to GalleryProperty. GalleryProperties p =3D new GalleryProperties(); p.load(new StringBufferInputStream(response)); It is fine when response characters encoded in one byte but wrong in = double bytes (ex: chinese), Java Properties(GalleryProperties extend it) load double bytes character = which must be formated in Unicode String format (ex: \u00FC). So I write a utility class(I "reuse" and modify the code in java = Properties class ) and trans response string to unicode string format. =20 response =3D StringUtil.toCharacterUnicodeString(response); GalleryProperties p =3D new GalleryProperties(); p.load(new StringBufferInputStream(response)); Then I rebuild it ,zip it and replace the origianl Jar File. Now, my gallery remote can work perfectly. But, I still can't not replace jar file which is used by gallery applet, = It cause a SHA security exception when Browser Load applet. Gallery is very good and useful for me.=20 I hope my resoulation is helpful to who use gallery remote and double = bytes character. Best regards, Dennis Chen form taiwan att...@se... =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D StringUtil source code is below /* * Created on 2004/10/2 */ package util; /** * @author Dennis Chen *=20 */ public class StringUtil { private static final String specialSaveChars =3D ""; public static String toCharacterUnicodeString(String theString) { return toCharacterUnicodeString(theString, false); } public static String toCharacterUnicodeString(String theString, boolean escapeSpace) { int len =3D theString.length(); StringBuffer outBuffer =3D new StringBuffer(len * 2); for (int x =3D 0; x < len; x++) { char aChar =3D theString.charAt(x); switch (aChar) { case '\n': default: if ((aChar < 0x0020) || (aChar > 0x007e)) { outBuffer.append('\\'); outBuffer.append('u'); outBuffer.append(toHex((aChar >> 12) & 0xF)); outBuffer.append(toHex((aChar >> 8) & 0xF)); outBuffer.append(toHex((aChar >> 4) & 0xF)); outBuffer.append(toHex(aChar & 0xF)); } else { if (specialSaveChars.indexOf(aChar) !=3D -1) outBuffer.append('\\'); outBuffer.append(aChar); } } } return outBuffer.toString(); } private static char toHex(int nibble) { return hexDigit[(nibble & 0xF)]; } /** A table of hex digits */ private static final char[] hexDigit =3D { '0', '1', '2', '3', '4', = '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; } |