Created
June 3, 2015 14:03
-
-
Save tamtam180/29028c011abdd36ae0ef 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
# coding: utf-8 | |
require 'json' | |
require 'yajl' | |
x = eval('{"logType"=>"ads", "abc"=>"\xE3\x82\xA4\xE3\x83\xB3\xE3\x82\xB9\xE3\x83\x88\xE3\x83\xBC\xE3\x83\xAB", "time"=>"2015-05-17T03:00:00Z", "tag"=>"aaa"}') | |
puts x["abc"].force_encoding("ASCII-8BIT") | |
puts x["abc"].encoding | |
puts x | |
puts Yajl.dump(x) | |
puts JSON.dump(x) |
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
インストール | |
ASCII-8BIT | |
{"logType"=>"ads", "abc"=>"\xE3\x82\xA4\xE3\x83\xB3\xE3\x82\xB9\xE3\x83\x88\xE3\x83\xBC\xE3\x83\xAB", "time"=>"2015-05-17T03:00:00Z", "tag"=>"aaa"} | |
{"logType":"ads","abc":"インストール","time":"2015-05-17T03:00:00Z","tag":"aaa"} | |
/Library/Ruby/Gems/2.0.0/gems/json-1.8.1/lib/json/common.rb:223:in `encode': "\xE3" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError) | |
from /Library/Ruby/Gems/2.0.0/gems/json-1.8.1/lib/json/common.rb:223:in `generate' | |
from /Library/Ruby/Gems/2.0.0/gems/json-1.8.1/lib/json/common.rb:223:in `generate' | |
from /Library/Ruby/Gems/2.0.0/gems/json-1.8.1/lib/json/common.rb:394:in `dump' | |
from hoge.rb:12:in `<main>' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
本質的な流れは以下のような感じですかね。in_tail側が悪いような気もしますが、どうしたものかな