Skip to content

Instantly share code, notes, and snippets.

@iorionda
Created May 1, 2013 05:56
Show Gist options
  • Select an option

  • Save iorionda/5493950 to your computer and use it in GitHub Desktop.

Select an option

Save iorionda/5493950 to your computer and use it in GitHub Desktop.
#!/usr/local/opt/rbenv/shims/ruby
# -*- coding: utf-8 -*-
require 'nokogiri'
str =<<HTML
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<title>Shift-JISのHTMLメール</title>
</head>
<body>
<p><a href="#">&copy;</a></p>
<p><a href="#">&nbsp;</a></p>
<p><a href="#">あいうえお</a></p>
<p><a href="#">abcde</a></p>
</body>
</html>
HTML
doc = Nokogiri::HTML(str, nil, 'ASCII-8BIT')
puts doc.to_html
@iorionda
Copy link
Copy Markdown
Author

iorionda commented May 1, 2013

Nokogiri で制御文字列を変換しないようにしたい。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment