Sha256: 9cc73fde685d75658207dfe1cd62ad46b6084de33c9bbf9d336075ec11ac6ba1

Contents?: true

Size: 752 Bytes

Versions: 2

Compression:

Stored size: 752 Bytes

Contents

## -*- Ruby -*-
## Sample XMLEncoding class for Japanese (EUC-JP, Shift_JIS)
## 1998 by yoshidam
##
## Usage:
##    require 'xml/encoding-ja'
##    include XML::Encoding_ja

module XML
module Encoding_ja
  require 'xml/parser'
  require 'uconv'

  class EUCHandler<XML::Encoding
    def map(i)
      return i if i < 128
      return -1 if i < 160 or i == 255
      return -2 
    end
    def convert(s)
      Uconv.euctou2(s)
    end
  end

  class SJISHandler<XML::Encoding
    def map(i)
      return i if i < 128
      return -2 
    end
    def convert(s)
      Uconv.sjistou2(s)
    end
  end

  def unknownEncoding(name)
    return EUCHandler.new if name =~ /^euc-jp$/i
    return SJISHandler.new if name =~ /^shift_jis$/i
    nil
  end

end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
mame-xmlparser-0.6.81.1 lib/xml/encoding-ja.rb
xmlparser-0.6.81 lib/xml/encoding-ja.rb