为什么有些红宝石整数不能元帅转储到to_json

时间:2019-05-12 16:54:59

标签: ruby encoding utf-8

运行此代码,可以将略多于整数的一半解析为json。我想了解这里的原因,假设我对编码一无所知。

红宝石2.5.1

(1..1000).each do |i|
  begin
    Marshal.dump(i).to_json
    puts i
  rescue => e
    puts "#{i} #{e.message}"
  end
end


756"\xF4" from ASCII-8BIT to UTF-8
757"\xF5" from ASCII-8BIT to UTF-8
758"\xF6" from ASCII-8BIT to UTF-8
759"\xF7" from ASCII-8BIT to UTF-8
760"\xF8" from ASCII-8BIT to UTF-8
761"\xF9" from ASCII-8BIT to UTF-8
762"\xFA" from ASCII-8BIT to UTF-8
763"\xFB" from ASCII-8BIT to UTF-8
764"\xFC" from ASCII-8BIT to UTF-8
765"\xFD" from ASCII-8BIT to UTF-8
766"\xFE" from ASCII-8BIT to UTF-8
767"\xFF" from ASCII-8BIT to UTF-8
768
769
770
771
772
773
774
775
776
777

0 个答案:

没有答案