Last active
December 15, 2015 16:29
-
-
Save hamakn/5289545 to your computer and use it in GitHub Desktop.
prelの内部文字列がわかってなくて死んだ
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
use 5.016; | |
use utf8; | |
use Encode; | |
use Encode::Guess qw/utf8 euc-jp shiftjis/; | |
my $str = 'あああ'; | |
say guess_encoding($str)->name; | |
# => utf8 | |
say $str eq encode_utf8($str); | |
# => '' | |
say $str eq encode_utf8(encode_utf8($str)); | |
# => '' | |
say encode_utf8($str) eq encode_utf8(encode_utf8($str)); | |
# => '' |
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 | |
# ↑ (ruby2.0以降であればdefault encodingはutf8なので不要) | |
str = "あああ" | |
p str.encoding | |
# => #<Encoding:UTF-8> | |
p str == str.encode("UTF-8") | |
# => true | |
p str == str.encode("UTF-8").encode("UTF-8") | |
# => true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment