convert a string encoding which retrieved from filesystem

The OSX filesystem uses UTF8-MAC as file name encoding.
Its encoding has a character that does not match UTF-8 encoding.
(ex, "が" in Japanese)
This commit is contained in:
Watson
2013-02-10 02:18:19 +09:00
parent 1abba61042
commit 25ee0b4cb4

View File

@@ -456,6 +456,7 @@ EOS
# Delete old resource files.
Dir.chdir(bundle_path) do
Dir.glob('**/*').each do |bundle_res|
bundle_res = convert_filesystem_encoding(bundle_res)
next if File.directory?(bundle_res)
next if reserved_app_bundle_files.include?(bundle_res)
next if resources_files.include?(bundle_res)
@@ -478,6 +479,16 @@ EOS
end
end
def convert_filesystem_encoding(string)
begin
string.encode("UTF-8", "UTF8-MAC")
rescue
# for Ruby 1.8
require 'iconv'
Iconv.conv("UTF-8", "UTF8-MAC", string)
end
end
def codesign(config, platform)
bundle_path = config.app_bundle(platform)
raise unless File.exist?(bundle_path)