我认为这是'cp1252',别名'windows-1252'。
阅读Jörg的回答后,我回到ruby-doc.org上的Encoding页面,试图找到他提到的具体编码的参考,这就是当我发现Encodings.aliases
方法。
所以我在这个答案的最后对这个方法进行了分析。
然后我看着在记事本+ +的输出,将其视为两个“ANSI”和UTF-8,和比较,要在IRB输出...
我只能找到在IRB输出两个地方其中utf-8文件与查看“ANSI”时出现在记事本++中的方式完全相同,并且这些地方用于cp1252和cp1254。
cp1252显然是我的'文件系统'编码,所以我就这样做了。
我写了一个脚本,以使所有的文件的副本转换为UTF-8的,试图从两者1252和1254
UTF-8正则表达式似乎有两套文件至今工作。
现在我必须尝试记住我在尝试完成之前完成之前遇到过所有这些编码问题。的xD
def compare_encodings file1, file2
file1_probs = []
file2_probs = []
txt = File.open('encoding_test_output.txt','w')
Encoding.aliases.sort.each do |k,v|
Encoding.default_external=k
ename = [k.downcase, v.downcase].join " --- "
s = ""
begin
s << "#{File.read(file1)}"
rescue
s << "nope nope nope"
file1_probs << ename
end
s << "\t| #{ename} |\t"
begin
s << "#{File.read(file2)}"
rescue
s << "nope nope nope"
file2_probs << ename
end
Encoding.default_external= 'utf-8'
txt.puts s.center(58)
puts s.center(58)
end
puts
puts "file1, \"#{file1}\" exceptions from trying to convert to:\n\n"
puts file1_probs
puts
puts "file2, \"#{file2}\" exceptions from trying to convert to:\n\n"
puts file2_probs
txt.close
end
compare_encodings "utf-8.txt", "np++'ANSI'.txt"
这取决于你的操作系统语言环境。对于德语或英语,它是Windows-1252。虽然Notepad ++可能不会遵循这一点,只是将它用作Windows-1252的别名。这当然不是任何ISO编码。见http://en.wikipedia.org/wiki/Windows_ANSI_code_page#ANSI_code_page – Esailija
谢谢,我认为这是cp1252,是的。 –