Created
June 27, 2012 00:51
-
-
Save momo-lab/3000522 to your computer and use it in GitHub Desktop.
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 -Ku | |
require 'nkf' | |
class String | |
def printable! | |
self.each_char.find_all{|ch| NKF.guess(ch) == NKF::UTF8}.join("") | |
end | |
end | |
require 'test/unit' | |
class PrintableTest < Test::Unit::TestCase | |
def test_printable | |
assert_equal "あいえお", "あ\000い\343う\201え\202お".printable! | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment