Changeset 456:371df097a76e

Show
Ignore:
Timestamp:
06/09/07 23:28:56 (18 months ago)
Author:
ser
Branch:
default
convert_revision:
svn:877f57f0-f5bd-0310-8c13-bb9e5bdefd87/trunk@1255
Message:

r1279@bean: ser | 2007-06-09 23:19:02 -0400
Fixes ticket:89 -- encoding CP-1252 was broken. ISO-8859-15 had the same
problem.

Also in this patch is a fix to merge.rb (unused, but it should at least
contain no errors), and a unit test for ticket:88.

Files:
5 modified

Legend:

Unmodified
Added
Removed
  • bin/merge.rb

    r455 r456  
    4141Name: svn:executable 
    4242   + * 
     43=end 
    4344 
    4445 
    45  
  • src/rexml/encodings/CP-1252.rb

    r287 r456  
    44module REXML 
    55  module Encoding 
    6     @@__REXML_encoding_methods = %q~ 
     6        register( "CP-1252" ) do |o| 
     7                class << o 
     8                        alias encode encode_cp1252 
     9                        alias decode decode_cp1252 
     10                end 
     11        end 
     12 
    713    # Convert from UTF-8 
    8     def encode content 
     14    def encode_cp1252(content) 
    915      array_utf8 = content.unpack('U*') 
    1016      array_enc = [] 
     
    5561     
    5662    # Convert to UTF-8 
    57     def decode(str) 
     63    def decode_cp1252(str) 
    5864      array_latin9 = str.unpack('C*') 
    5965      array_enc = [] 
     
    94100      array_enc.pack('U*') 
    95101    end 
    96     ~ 
    97102  end 
    98103end 
  • src/rexml/encodings/ISO-8859-15.rb

    r288 r456  
    44module REXML 
    55  module Encoding 
    6     @@__REXML_encoding_methods = %q~ 
     6        register("ISO-8859-15") do |o| 
     7                alias encode to_iso_8859_15 
     8                alias decode from_iso_8859_15 
     9        end 
     10 
    711    # Convert from UTF-8 
    8     def to_iso_8859_15 content 
     12    def to_iso_8859_15(content) 
    913      array_utf8 = content.unpack('U*') 
    1014      array_enc = [] 
     
    6569      array_enc.pack('U*') 
    6670    end 
    67     ~ 
    6871  end 
    6972end 
  • test/core_test.rb

    r455 r456  
    12091209    assert_equal( sanity1, sanity2 ) 
    12101210  end 
     1211   
     1212  def test_ticket_88 
     1213    doc = REXML::Document.new("<?xml version=\"1.0\" encoding=\"shift_jis\"?>") 
     1214    assert_equal("<?xml version='1.0' encoding='SHIFT_JIS'?>", doc.to_s) 
     1215    doc = REXML::Document.new("<?xml version = \"1.0\" encoding = \"shift_jis\"?>") 
     1216    assert_equal("<?xml version='1.0' encoding='SHIFT_JIS'?>", doc.to_s) 
     1217  end 
    12111218end 
  • test/encoding.rb

    r390 r456  
    6868    assert_equal( doc.elements['a'].text, "\303\277" ) 
    6969  end 
     70 
     71 
     72  def test_ticket_89 
     73    doc = Document.new <<-EOL 
     74       <?xml version="1.0" encoding="CP-1252" ?> 
     75       <xml><foo></foo></xml> 
     76       EOL 
     77 
     78    REXML::Document.new doc 
     79  end 
    7080end