Tag: arabic

使用Ruby(IRB)打印CP850编码的字符串

我想打开一个包含阿拉伯语文本的文本文件(test.txt)(其编码为CP850),然后将其内容打印到STDOUT: # coding : CP850 STDOUT.set_encoding(Encoding::CP850); # not sure if it’s necessary open(‘G:/test.txt’,?r){|f| f.read.each_char{|c| print c}; # or puts f.read; } gets 但它不打印阿拉伯字符,输出是一些符号和随机字符。 使用Ruby 2.2.3