class Object
Public Instance Methods
StringToWSTR(str, encoding = 'UTF-16LE')
click to toggle source
# File lib/live_identity/idcrl.rb, line 28 def StringToWSTR(str, encoding = 'UTF-16LE') [str.encode('UTF-16LE')].pack('a*xx') end
getStringLength(data)
click to toggle source
# File lib/live_identity/idcrl.rb, line 10 def getStringLength(data) length = 0 count = 0 offset = 0 previous = nil while count < 2 data.get_bytes(offset, 100).each_byte do |byte| length = length + 1 count = count + 1 if byte.zero? and previous.zero? previous = byte return length - 2 if count >= 2 end offset += 100 break if offset >= 100000 end length end
read_wide_string(data, encoding = 'UTF-16LE')
click to toggle source
# File lib/live_identity/idcrl.rb, line 32 def read_wide_string(data, encoding = 'UTF-16LE') data.read_bytes(getStringLength(data)).force_encoding(encoding).encode('UTF-8') end