Created
February 23, 2009 03:35
-
-
Save ukstudio/68774 to your computer and use it in GitHub Desktop.
This file contains 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
# coding: UTF-8 | |
str_utf = "hoge" | |
str_euc = "hoge".encode("EUC-JP") | |
# ASCII互換コーディングをもつ7bitクリーンな文字列は | |
# エンコーディングに関わらずASCIIとして扱える | |
p str_utf == str_euc #=> true | |
p /hoge/ =~ str_utf #=> 0 | |
p /hoge/ =~ str_euc #=> 0 | |
str_utf_multi_byte = "あいうえお" | |
str_euc_multi_byte = "あいうえお".encode("EUC-JP") | |
p str_utf_multi_byte == str_euc_multi_byte #=> false | |
p /あいうえお/ =~ str_utf_multi_byte #=> 0 | |
p /あいうえお/ =~ str_euc_multi_byte #=> Encoding::CompatibilityError |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment