aussiegeek/rubyzip — Issue #33: zip archive broken (CRC Error) on Windows  when using utf-8 encoded string on Ruby 1.9.x
Author: skoji
Created: 2012-03-03 02:16:12+00:00
State: open

this code will reproduce the problem in the following environments:
1. ruby-1.9.3-p0 + MacOS X 10.7.3 + rubyzip 0.9.6.1
2. ruby-1.9.3-p125 + Windows 7 + rubyzip 0.9.6.1

'test_broken_on_1.9.3.zip' seems OK on MacOS, but can't extract on Windows 7 or Windows XP because of CRC error.

# -*- coding: utf-8 -*-
Zip::ZipOutputStream.open('test_broken_on_1.9.3.zip') {
|zos|
zos.put_next_entry('test.txt')
zos << '日本語 Japanese Character in text.'
}

Zip::ZipOutputStream.open('test_not_broken.zip') {
|zos|
zos.put_next_entry('test.txt')
zos << '日本語 Japanese Character in text.'.force_encoding('us-ascii')
}