class Android::Resource::ResStringPool
Constants
- SORTED_FLAG
- UTF8_FLAG
Attributes
strings[R]
Private Class Methods
utf16_len(data)
click to toggle source
@note refer to /frameworks/base/libs/androidfw/ResourceTypes.cpp
static inline size_t decodeLength(const char16_t** str)
@param [String] data parse target @return[Integer, Integer] string length and parsed length
# File lib/android/resource.rb, line 101 def self.utf16_len(data) first, second = data.unpack('vv') if (first & 0x8000) != 0 return (((first & 0x7FFF) << 16) + second), 4 else return first, 2 end end
utf8_len(data)
click to toggle source
@note refer to /frameworks/base/libs/androidfw/ResourceTypes.cpp
static inline size_t decodeLength(const uint8_t** str)
@param [String] data parse target @return[Integer, Integer] string length and parsed length
# File lib/android/resource.rb, line 89 def self.utf8_len(data) first, second = data.unpack('CC') if (first & 0x80) != 0 return (((first & 0x7F) << 8) + second), 2 else return first, 1 end end
Private Instance Methods
parse()
click to toggle source
Calls superclass method
Android::Resource::ChunkHeader#parse
# File lib/android/resource.rb, line 59 def parse super @string_count = read_int32 @style_count = read_int32 @flags = read_int32 @string_start = read_int32 @style_start = read_int32 @strings = [] @string_count.times do offset = @offset + @string_start + read_int32 if (@flags & UTF8_FLAG != 0) # read length twice(utf16 length and utf8 length) # const uint16_t* ResStringPool::stringAt(size_t idx, size_t* u16len) const u16len, o16 = ResStringPool.utf8_len(@data[offset, 2]) u8len, o8 = ResStringPool.utf8_len(@data[offset+o16, 2]) str = @data[offset+o16+o8, u8len] @strings << str.force_encoding(Encoding::UTF_8) else u16len, o16 = ResStringPool.utf16_len(@data[offset, 4]) str = @data[offset+o16, u16len*2] str.force_encoding(Encoding::UTF_16LE) @strings << str.encode(Encoding::UTF_8) end end end