Created
April 21, 2016 14:29
-
-
Save choipd/750657a7728c93bccabe76a086fbce27 to your computer and use it in GitHub Desktop.
한글 CP949 압축된 파일 풀기
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'fileutils' | |
require 'zip' | |
def unzip | |
Zip::File.open(ARGV[0]) { |zipfile| | |
zipfile.each {|f| | |
# cp949 파일 이름을 utf-8로 변환 | |
utf_string = f.name.force_encoding("CP949").encode("UTF-8", :invalid => :replace, :undef => :replace, :replace => "_") # for ruby1.9 or higher | |
FileUtils.mkdir_p(File.dirname(utf_string)) | |
#zipfile.extract(f,utf_string) | |
f.extract(utf_string) | |
puts utf_string | |
} | |
} | |
end | |
unzip |
dependance: gem install zip
usage:
ruby unzip_c949.rb a.zip
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://blog.lvu.kr/한글-zip-파일-풀기/