Method: REXML::Encoding#encode_unile

Defined in:
lib/extensions/rexml/rexml/encodings/UNILE.rb

#encode_unile(content) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/extensions/rexml/rexml/encodings/UNILE.rb', line 3

def encode_unile content
  array_utf8 = content.unpack("U*")
  array_enc = []
  array_utf8.each do |num|
    if ((num>>16) > 0)
      array_enc << ??
      array_enc << 0
    else
      array_enc << (num & 0xFF)
      array_enc << (num >> 8)
    end
  end
  array_enc.pack('C*')
end