I use ruby reading a web page, and its content is:
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=GB2312" />
</HEAD>
<BODY>
中文
</BODY>
</HTML>
From the meta, we can see it uses a GB2312
encoding.
My code is:
res = Net::HTTP.post_form(URI.parse("http://xxx/check"),
{:query=>'xxx'})
Then I use:
res.include?("中文")
to check if the content has that word. But if shows false
.
I don't know why it is false, and what should I do? What encoding ruby 1.8.7 use? If I need to convert the encoding, how to do it?