COMMUNITY

How to read an utf8 string from a zip file


(Mathieuanthoine) #1

Hi everyone,

I try to read a json file encoded in utf8 that is zip.
I have no problem with a ANSI file but not get the result with utf8 file.
I tried to decode with the UTF8 class but it doesn’t work, found code about Uncompress or deflate compress files in a zip but it’s code from old haxe version.
I’m not able to find recent example about the subject.
Is someone have something that work ?

Thank you for your help.

Here’s my example with an ANSI file.

// I use OpenFl
var entries:List<Entry> = Reader.readZip(Assets.getBytes("my.zip")); 
var searchEntryFileName = "my.json";
for (entry in entries) {
	trace (entry.fileName);
	trace (entry.compressed);
	if (entry.fileName == searchEntryFileName) trace (entry.data.toString());
}

(tokiop) #2

Hi,

have you solved the issue ? Not sure it can help with utf8, but this worked for me to uncompress :

if (entry.compressed){
	entry.data = haxe.zip.Reader.unzip(entry);
}