Sha256: 27413dfcd380990f86db503df2591b0d978c57f72b81c8afdf171ff5afa2bd67

Contents?: true

Size: 711 Bytes

Versions: 339

Compression:

Stored size: 711 Bytes

Contents

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

module Nokogiri
  module HTML
    if RUBY_VERSION =~ /^1\.9/
      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
end

Version data entries

339 entries across 339 versions & 33 rubygems

Version Path
nokogiri-1.6.6.1-java test/html/test_node_encoding.rb
nokogiri-1.6.6.1 test/html/test_node_encoding.rb
nokogiri-1.6.5 test/html/test_node_encoding.rb
nokogiri-1.6.5-x86-mingw32 test/html/test_node_encoding.rb
nokogiri-1.6.5-x64-mingw32 test/html/test_node_encoding.rb
nokogiri-1.6.5-java test/html/test_node_encoding.rb
nokogiri-1.6.4.1 test/html/test_node_encoding.rb
nokogiri-1.6.4.1-x86-mingw32 test/html/test_node_encoding.rb
nokogiri-1.6.4.1-x64-mingw32 test/html/test_node_encoding.rb
nokogiri-1.6.4.1-java test/html/test_node_encoding.rb
nokogiri-1.6.4 test/html/test_node_encoding.rb
nokogiri-1.6.4-x86-mingw32 test/html/test_node_encoding.rb
nokogiri-1.6.4-x64-mingw32 test/html/test_node_encoding.rb
nokogiri-1.6.4-java test/html/test_node_encoding.rb
nokogiri-1.6.3.1 test/html/test_node_encoding.rb
nokogiri-1.6.3.1-x86-mingw32 test/html/test_node_encoding.rb
nokogiri-1.6.3.1-x64-mingw32 test/html/test_node_encoding.rb
nokogiri-1.6.3.1-java test/html/test_node_encoding.rb
nokogiri-1.6.3 test/html/test_node_encoding.rb
nokogiri-1.6.3-x86-mingw32 test/html/test_node_encoding.rb