Doesn't work correctly.
If the archive contains files whose names have ANSI characters in the same places, then only the first file can be opened.
The second and subsequent archive files are not opened, instead the first file is opened again (because get_files() converts the unique name to �����txt).

Example:

  • Test.zip
    -- ФайлА.txt
    --- "Text in file 1"
    -- ФайлБ.txt
    --- "Text in file 2"
	var zip = ZIPReader.new()
	if zip.open(test_zip_path) == OK:
		for file_name in zip.get_files():
			var zip_file = zip.read_file(file_name)
			printerr(zip_file.get_string_from_utf8())

Result

Text in file 1
Text in file 1

This is an error due to get_files()

  • xyz replied to this.

    ZBEP What's the byte content of retrieved filename strings when you do to_*_buffer()?

    • ZBEP replied to this.

      xyz ZIPReader does not allow to*buffer() on filenames before they are converted to �

      To get names only this is available:

      ● PackedByteArray read_file(path: String, case_sensitive: bool = true)

      Loads the whole content of a file in the loaded zip archive into memory and returns it.

      Must be called after open().

      I can only use to*buffer() on a converted name that already has the characters replaced with �

      extends Control
      
      
      # Called when the node enters the scene tree for the first time.
      func _ready() -> void:
      	var zip = ZIPReader.new()
      	if zip.open("res://Test.zip") == OK:
      		for file_name in zip.get_files():
      			var file = zip.read_file(file_name)
      			print(file_name.to_utf8_buffer(), "\n", file_name.to_ascii_buffer(), "\n", file.get_string_from_utf8())
      
      
      # Called every frame. 'delta' is the elapsed time since the previous frame.
      func _process(delta: float) -> void:
      	pass

      Unicode parsing error, some characters were replaced with � (U+FFFD): Invalid UTF-8 leading byte (92)
      Unicode parsing error, some characters were replaced with � (U+FFFD): Invalid UTF-8 leading byte (a5)
      Unicode parsing error, some characters were replaced with � (U+FFFD): Invalid UTF-8 continuation byte (e1 ... e2 ...)
      Unicode parsing error, some characters were replaced with � (U+FFFD): Invalid UTF-8 leading byte (80)
      Unicode parsing error, some characters were replaced with � (U+FFFD): Invalid UTF-8 leading byte (92)
      Unicode parsing error, some characters were replaced with � (U+FFFD): Invalid UTF-8 leading byte (a5)
      Unicode parsing error, some characters were replaced with � (U+FFFD): Invalid UTF-8 continuation byte (e1 ... e2 ...)
      Unicode parsing error, some characters were replaced with � (U+FFFD): Invalid UTF-8 leading byte (81)
      Unicode parsing error, some characters were replaced with � (U+FFFD): Invalid UTF-8 leading byte (92)
      Unicode parsing error, some characters were replaced with � (U+FFFD): Invalid UTF-8 leading byte (a5)
      Unicode parsing error, some characters were replaced with � (U+FFFD): Invalid UTF-8 continuation byte (e1 ... e2 ...)
      Unicode parsing error, some characters were replaced with � (U+FFFD): Invalid UTF-8 leading byte (80)
      Unicode parsing error: Invalid unicode codepoint (fffd), cannot represent as ASCII/Latin-1
      Unicode parsing error: Invalid unicode codepoint (fffd), cannot represent as ASCII/Latin-1
      Unicode parsing error: Invalid unicode codepoint (fffd), cannot represent as ASCII/Latin-1
      Unicode parsing error: Invalid unicode codepoint (fffd), cannot represent as ASCII/Latin-1
      [239, 191, 189, 239, 191, 189, 239, 191, 189, 239, 191, 189, 46, 116, 120, 116]
      [32, 32, 32, 32, 46, 116, 120, 116]
      Text in file 1
      Unicode parsing error, some characters were replaced with � (U+FFFD): Invalid UTF-8 leading byte (92)
      Unicode parsing error, some characters were replaced with � (U+FFFD): Invalid UTF-8 leading byte (a5)
      Unicode parsing error, some characters were replaced with � (U+FFFD): Invalid UTF-8 continuation byte (e1 ... e2 ...)
      Unicode parsing error, some characters were replaced with � (U+FFFD): Invalid UTF-8 leading byte (80)
      Unicode parsing error: Invalid unicode codepoint (fffd), cannot represent as ASCII/Latin-1
      Unicode parsing error: Invalid unicode codepoint (fffd), cannot represent as ASCII/Latin-1
      Unicode parsing error: Invalid unicode codepoint (fffd), cannot represent as ASCII/Latin-1
      Unicode parsing error: Invalid unicode codepoint (fffd), cannot represent as ASCII/Latin-1
      [239, 191, 189, 239, 191, 189, 239, 191, 189, 239, 191, 189, 46, 116, 120, 116]
      [32, 32, 32, 32, 46, 116, 120, 116]
      Text in file 1

      ZBEP Will you wait for it to get implemented or use one of the hacky solutions? 🙂

      • ZBEP replied to this.

        xyz I'll wait if it doesn't take too long.
        There are still a lot of things that I need to do in my projects 🙂