Rumah > Soal Jawab > teks badan
PHP中文网2017-04-24 09:11:43
Apabila menggunakan perpustakaan permata pihak ketiga, rhardet atau uchardet disyorkan
2.2.2 :001 > require 'rchardet'
=> true
2.2.2 :002 > CharDet.detect('测试')
=> {"encoding"=>"utf-8", "confidence"=>0.7525}
2.2.2 :003 >
PHP中文网2017-04-24 09:11:43
str="abc"
sty=str.encoding.name
if sty=="GBK"
puts "gbk"
elsif sty="UTF-8"
puts "utf8"
else
puts "not gbk or utf8"
end