From 25ee0b4cb40ff2ecae63b1988f2f7628038f013c Mon Sep 17 00:00:00 2001 From: Watson Date: Sun, 10 Feb 2013 02:18:19 +0900 Subject: [PATCH] convert a string encoding which retrieved from filesystem MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- lib/motion/project/builder.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/motion/project/builder.rb b/lib/motion/project/builder.rb index 2cdf2175..5c708217 100644 --- a/lib/motion/project/builder.rb +++ b/lib/motion/project/builder.rb @@ -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)