Ruby散列中保存中文,使用puts输出时只能显示unicode码,请问如何显示中文?
源码:
hash={a:"第一条",b:"第二条",c:"第三条"} puts hash
输出结果:
{:a=>"\u7B2C\u4E00\u6761", :b=>"\u7B2C\u4E8C\u6761", :c=>"\u7B2C\u4E09\u6761"}
人生最曼妙的风景,竟是内心的淡定与从容!
Open irb input
Encoding.locale_charmap
Check if your encoding is => "UTF-8"
The Ruby version must be greater than 1.8
Check whether you have readline installed
Warning: Trying to solve a non-existent problem.
I tested it on CentOS and Mac and didn’t find the problem you mentioned.
Open irb input
Encoding.locale_charmap
Check if your encoding is => "UTF-8"
The Ruby version must be greater than 1.8
Check whether you have readline installed
Warning: Trying to solve a non-existent problem.
I tested it on CentOS and Mac and didn’t find the problem you mentioned.