-
-
Save behrends/569222 to your computer and use it in GitHub Desktop.
umlauts and encoding in nokogiri
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'nokogiri' | |
doc = Nokogiri::HTML::Document.new | |
doc.encoding = 'UTF-8' | |
# We added a contextual fragment method for the 1.4.2 release. This *might* | |
# work in 1.4.1. If you want to mess with 1.4.2, build from my github, or | |
# grab one of our nightly builds: | |
# | |
# $ sudo gem install nokogiri -s http://tenderlovemaking.com/ | |
# | |
# Also, libxml2 had a bug with encoding when handling UTF-8 fragments, so I | |
# suggest you also upgrade to libxml2 2.7.7. | |
# | |
# Hope that helps! | |
puts doc.fragment('<p>ö</p>') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p>ö</p> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment