Sha256: bf37ab66d089923421d7c2190e9fad2db54c3255b815b78a95684780b88defef

Contents?: true

Size: 644 Bytes

Versions: 4

Compression:

Stored size: 644 Bytes

Contents

# -*- coding: utf-8 -*-
require "helper"

module Nokogiri
  module HTML
    class TestNodeEncoding < Nokogiri::TestCase
      def test_inner_html
        doc = Nokogiri::HTML File.open(SHIFT_JIS_HTML, 'rb')

        hello = "こんにちは"

        contents = doc.at('h2').inner_html
        assert_equal doc.encoding, contents.encoding.name
        assert_match hello.encode('Shift_JIS'), contents

        contents = doc.at('h2').inner_html(:encoding => 'UTF-8')
        assert_match hello, contents

        doc.encoding = 'UTF-8'
        contents = doc.at('h2').inner_html
        assert_match hello, contents
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
nokogiri-1.6.8.rc1 test/html/test_node_encoding.rb
nokogiri-1.6.8.rc1-x86-mingw32 test/html/test_node_encoding.rb
nokogiri-1.6.8.rc1-x64-mingw32 test/html/test_node_encoding.rb
nokogiri-1.6.8.rc1-java test/html/test_node_encoding.rb