From: JOUHIER B. <Bru...@sa...> - 2003-02-19 18:32:14
|
Hi Jochen, No, I don't have any magic suggestion that will work on all machines. This looks like a serious deficiency of the Zip file format. It is = lacking a global or local header field where you could record the charset used to encode the entry names (and the comments). So, you have to rely on the charset of the destination machine, and the file names will be messed = up if the source and destination machines don't have the same charset. To make things worse, you have to use the DOS charset (the ugly OEM = one, with semi-graphic chars, very different from ISO-Latin1) rather that = than the Windows charset (very close to ISO-Latin1) on Windows, and new String(bytes) gives you the Windows one! You should be able to fix it for Windows machines by calling new String(bytes, "Cp850") and string.getBytes("Cp850") (replace Cp850 by = the native DOS code page, I don't know how to get it). I fixed it differently because I am compiling with Visual J++, and I = could call the native CharToOem and OemToChar Win32 functions, but my hack = won't run with standard Java compilers. Bruno. -----Message d'origine----- De : Jochen Hoenicke [mailto:Hoe...@In...] Envoy=E9 : mercredi 19 f=E9vrier 2003 18:23 =C0 : JOUHIER Bruno; 'jaz...@li...' Objet : Re: [Jazzlib-developers] Zip library has problems with entry names that contain accentuated chars On Wednesday 19 February 2003 14:39, JOUHIER Bruno wrote: > ZipInputStream reads the entry name with: > String name =3D new String(buffer); > ZipOutputStream writes the entry name with: > byte[] name =3D entry.getName().getBytes(); >=20 > So, if the name contains chars outside of the ASCII range (00-7f), = the > library uses the JVM's default code page to convert them (ISO-8859-1 = on my > machine). This messes up the entry names because they are encoded in = DOS OEM > rather than ISO 8859-1 (=E9 becomes ?) I have no idea how to fix this and still support chinese and other encodings. See this bug report: http://sourceforge.net/tracker/?func=3Ddetail&atid=3D116807&aid=3D561821= &group_id=3D 16807 Do you have any suggestions? Jochen --=20 Jochen Hoenicke, University of Oldenburg, 26111 Oldenburg, Germany Email: hoe...@in... Tel: +49 441 798 3124 ------------------------------------------------------------------------= ---- ------------------------------------------ Ce message et tous les = fichiers qui y sont attach=E9s contiennent des informations confidentielles, exclusivement destin=E9es =E0 la personne =E0 laquelle elles sont = adress=E9es. Dans l=92hypoth=E8se o=F9 ce message ne vous serait pas destin=E9, nous vous = remercions de le retourner imm=E9diatement =E0 son =E9metteur et de le supprimer. = La publication, la distribution, l=92impression ou tout autre usage non = autoris=E9 de ce message est strictement interdit. Les id=E9es et opinions = contenues dans ce message sont celles de son auteur et ne repr=E9sentent pas = n=E9cessairement celles du Groupe Sage. |