Skip to content

Instantly share code, notes, and snippets.

@yasuyk
Last active December 11, 2015 02:19
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save yasuyk/4529646 to your computer and use it in GitHub Desktop.
Save yasuyk/4529646 to your computer and use it in GitHub Desktop.
EncodingをUTF8-MacからUTF-8に変換する。Preview.appで開いたPDFの内容をコピペすると、濁点、半濁点が別々の文字になってしまう問題を解決。
#!/usr/bin/env ruby
# http://sssslide.com/speakerdeck.com/a_matsuda/rails3-recipe-book-gaiden#114
ARGV.each do |file|
File.open(file,'r+:UTF8-MAC') do |f|
str = f.read
f.rewind
f.truncate(0)
f.set_encoding('UTF-8')
f.write(str)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment