Last active
December 11, 2015 02:19
-
-
Save yasuyk/4529646 to your computer and use it in GitHub Desktop.
EncodingをUTF8-MacからUTF-8に変換する。Preview.appで開いたPDFの内容をコピペすると、濁点、半濁点が別々の文字になってしまう問題を解決。
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/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