module XML::DOM

Module XML::DOM (XML::SimpleTree)

DOM-like APIs module.

Module XML::DOM (XML::SimpleTree)

Constants

Attribute

Class XML::DOM::Attr

superclass

Node

Public Class Methods

tou16(str) click to toggle source
# File lib/xml/dom/digest.rb, line 12
def self.tou16(str)
  if defined?(::Encoding)
    str.encode(::Encoding::UTF_16BE).force_encoding(::Encoding::ASCII_8BIT)
  else
    str.unpack("U*").map {|v|
      if v >= 0x10000 && v <= 0x10ffff
        ## surrogate pair
        hi = ((v - 0x10000) >> 10) | 0xd800
        low = (v & 1023) | 0xdc00
        [hi, low].pack("n*")
      else
        [v].pack("n*")
      end
    }.join
  end
end