Namespace

Files

Uconv

 rbuconv - Pure Ruby Unicode converter
 (c) 2003 by yoshidam

 $Id: rbuconv.rb,v 1.3 2003/05/15 15:22:43 yoshidam Exp $

 EUC-JP(Hojo Kanji) to UCS
 (c) 2003 by yoshidam

 $Id: eucjphojo_ucs.rb,v 1.1.1.1 2003/04/16 14:33:52 yoshidam Exp $

 CP932 to UCS
 (c) 2003 by yoshidam

 $Id: cp932_ucs.rb,v 1.1.1.1 2003/04/16 14:33:52 yoshidam Exp $

 EUC-JP to UCS
 (c) 2003 by yoshidam

 $Id: eucjp_ucs.rb,v 1.1.1.1 2003/04/16 14:33:52 yoshidam Exp $

 UCS to CP932
 (c) 2003 by yoshidam

 $Id: ucs_cp932.rb,v 1.1.1.1 2003/04/16 14:33:52 yoshidam Exp $

 UCS to EUC-JP
 (c) 2003 by yoshidam

 $Id: ucs_eucjp.rb,v 1.1.1.1 2003/04/16 14:33:52 yoshidam Exp $

Constants

REPLACEMENT_CHAR
UTF-8, UTF-16 and USC-4 (UTF-32)
MultiByteToWideChar
(Not documented)
WideCharToMultiByte
(Not documented)
SJIS_CODEPAGE
(Not documented)
UNKNOWN_CHAR
Japanese

Public Instance Methods

eliminate_zwnbsp() click to toggle source

(Not documented)

# File rbuconv.rb, line 440
  def eliminate_zwnbsp
    false
  end
eliminate_zwnbsp=(arg) click to toggle source

(Not documented)

# File rbuconv.rb, line 444
  def eliminate_zwnbsp=(arg)
    raise NotImplementedError.new("not implemented")
  end
euctou16(str) click to toggle source

(Not documented)

# File rbuconv.rb, line 298
  def euctou16(str)
    ret = euctoucs(str).pack('v*')
    ret.taint if str.tainted?
    ret
  end
Also aliased as: euctou2
euctou2(str) click to toggle source

Alias for euctou16

euctou8(str) click to toggle source

(Not documented)

# File rbuconv.rb, line 292
  def euctou8(str)
    ret = euctoucs(str).pack('U*')
    ret.taint if str.tainted?
    ret
  end
getEUCJPHojotoUCSMap() click to toggle source

(Not documented)

# File rbuconv.rb, line 136
  def getEUCJPHojotoUCSMap
    if !defined?(@@EUCJPHojotoUCSMap)
      puts "loading..." if $DEBUG
      require 'uconv/eucjphojo_ucs'
    end
    @@EUCJPHojotoUCSMap
  end
replace_invalid() click to toggle source

(Not documented)

# File rbuconv.rb, line 456
  def replace_invalid
    true
  end
replace_invalid=(arg) click to toggle source

(Not documented)

# File rbuconv.rb, line 460
  def replace_invalid=(arg)
    raise NotImplementedError.new("not implemented")
  end
shortest() click to toggle source

(Not documented)

# File rbuconv.rb, line 448
  def shortest
    false
  end
shortest=(arg) click to toggle source

(Not documented)

# File rbuconv.rb, line 452
  def shortest=(arg)
    raise NotImplementedError.new("not implemented")
  end
sjistou16(str) click to toggle source

(Not documented)

# File rbuconv.rb, line 420
  def sjistou16(str)
    ret = sjistoucs(str).pack('v*')
    ret.taint if str.tainted?
    ret
  end
Also aliased as: sjistou2
sjistou2(str) click to toggle source

Alias for sjistou16

sjistou8(str) click to toggle source

(Not documented)

# File rbuconv.rb, line 414
  def sjistou8(str)
    ret = sjistoucs(str).pack('U*')
    ret.taint if str.tainted?
    ret
  end
sjistoucs(str) click to toggle source

Shift_JIS (CP932)

# File rbuconv.rb, line 319
  def sjistoucs(str)
    i = 0
    len = str.length
    ret = []
    map = getCP932toUCSMap
    while i < len
      c = str[i]
      if c <= 0x7f
        ret << c
      elsif c >= 0x80 && c <= 0xfc
        u = REPLACEMENT_CHAR
        if i+1 < len && str[i+1] >= 0x40 && str[+1] <= 0xfc
          u = 0
          i += 1
          hi = c
          low = str[i]
          if hi >= 0xe0
            pos = (hi - 0xc1)*188
          else
            pos = (hi - 0x81)*188
          end
          if low >= 0x80
            pos += low - 0x41
          else
            pos += low - 0x40
          end
          if pos < 11280
            pos = pos * 2
            u = (map[pos] << 8) | map[pos + 1]
          end
          if u == 0
            ## unknown SJIS character
            if respond_to?(:unknown_sjis_handler)
              u = unknown_sjis_handler([hi, low].pack('cc'))
            else
              u = REPLACEMENT_CHAR
            end
          end
        end
        ret << u
      elsif c >= 0xa0 && c <= 0xdf
        u = 0xff00 | (c - 0x40)
        ret << u
      else
        ## invalid character
        ret << REPLACEMENT_CHAR
      end
      i += 1
    end
    ret
  end
u16swap(str) click to toggle source

(Not documented)

# File rbuconv.rb, line 100
  def u16swap(str)
    ret = str.unpack('n*').pack('v*')
    ret.taint if str.tainted?
    ret
  end
Also aliased as: u2swap
u16swap!(str) click to toggle source

(Not documented)

# File rbuconv.rb, line 107
  def u16swap!(str)
    str[0..-1] = u16swap(str)
  end
Also aliased as: u2swap!
u16toeuc(str) click to toggle source

(Not documented)

# File rbuconv.rb, line 311
  def u16toeuc(str)
    ret = ucstoeuc(combineSurrogatePair(str.unpack('v*')))
    ret.taint if str.tainted?
    ret
  end
Also aliased as: u2toeuc
u16tosjis(str) click to toggle source

(Not documented)

# File rbuconv.rb, line 433
  def u16tosjis(str)
    ret = ucstosjis(combineSurrogatePair(str.unpack('v*')))
    ret.taint if str.tainted?
    ret
  end
Also aliased as: u2tosjis
u16tou4(str) click to toggle source

(Not documented)

# File rbuconv.rb, line 82
  def u16tou4(str)
    ret = combineSurrogatePair(str.unpack('v*')).pack('V*')
    ret.taint if str.tainted?
    ret
  end
u16tou8(str) click to toggle source

(Not documented)

# File rbuconv.rb, line 75
  def u16tou8(str)
    ret = combineSurrogatePair(str.unpack('v*')).pack('U*')
    ret.taint if str.tainted?
    ret
  end
Also aliased as: u2tou8
u2swap(str) click to toggle source

Alias for u16swap

u2swap!(str) click to toggle source

Alias for u16swap!

u2toeuc(str) click to toggle source

Alias for u16toeuc

u2tosjis(str) click to toggle source

Alias for u16tosjis

u2tou8(str) click to toggle source

Alias for u16tou8

u4swap(str) click to toggle source

(Not documented)

# File rbuconv.rb, line 112
  def u4swap(str)
    ret = str.unpack('N*').pack('V*')
    ret.taint if str.tainted?
    ret
  end
u4swap!(str) click to toggle source

(Not documented)

# File rbuconv.rb, line 118
  def u4swap!(str)
    str[0..-1] = u4swap(str)
  end
u4tou16(str) click to toggle source

(Not documented)

# File rbuconv.rb, line 94
  def u4tou16(str)
    ret = divideSurrogatePair(str.unpack('V*')).pack('v*')
    ret.taint if str.tainted?
    ret
  end
u4tou8(str) click to toggle source

(Not documented)

# File rbuconv.rb, line 88
  def u4tou8(str)
    ret = str.unpack('V*').pack('U*')
    ret.taint if str.tainted?
    ret
  end
u8toeuc(str) click to toggle source

(Not documented)

# File rbuconv.rb, line 305
  def u8toeuc(str)
    ret = (ucstoeuc(str.unpack('U*')) rescue raise Uconv::Error.new($!))
    ret.taint if str.tainted?
    ret
  end
u8tosjis(str) click to toggle source

(Not documented)

# File rbuconv.rb, line 427
  def u8tosjis(str)
    ret = (ucstosjis(str.unpack('U*')) rescue raise Uconv::Error.new($!))
    ret.taint if str.tainted?
    ret
  end
u8tou16(str) click to toggle source

(Not documented)

# File rbuconv.rb, line 60
  def u8tou16(str)
    ret = (divideSurrogatePair(str.unpack('U*')).pack('v*') rescue
           raise Uconv::Error.new($!))
         
    ret.taint if str.tainted?
    ret
  end
Also aliased as: u8tou2
u8tou2(str) click to toggle source

Alias for u8tou16

u8tou4(str) click to toggle source

(Not documented)

# File rbuconv.rb, line 69
  def u8tou4(str)
    ret = (str.unpack('U*').pack('V*') rescue raise Uconv::Error.new($!))
    ret.taint if str.tainted?
    ret
  end

Disabled; run with $DEBUG to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.