@internal class Char { @internal fun toInt() -> Int; @internal fun toLong() -> Long; @internal fun toString() -> String; @internal fun equals(rhs: Char) -> Bool; @internal fun compareTo(rhs: Char) -> Int; fun hash() -> Int = self.toInt(); fun encodeUtf8(bytes: Array[Byte], offset: Int) { let val = self.toInt(); if val < 0x80 { bytes.set(offset, val.toByte()); } else if val < 0x800 { bytes.set(offset, (0xC0 | ((val >> 6) & 0x1F)).toByte()); bytes.set(offset+1, (0x80 | (val & 0x3F)).toByte()); } else if val < 0x10000 { bytes.set(offset, (0xE0 | ((val >> 12) & 0x0F)).toByte()); bytes.set(offset+1, (0x80 | ((val >> 6) & 0x3F)).toByte()); bytes.set(offset+2, (0x80 | (val & 0x3F)).toByte()); } else { bytes.set(offset, (0xF0 | ((val >> 18) & 0x07)).toByte()); bytes.set(offset+1, (0x80 | ((val >> 12) & 0x3F)).toByte()); bytes.set(offset+2, (0x80 | ((val >> 6) & 0x3F)).toByte()); bytes.set(offset+3, (0x80 | (val & 0x3F)).toByte()); } } fun lenUtf8() -> Int { let val = self.toInt(); if val < 0x80 { return 1; } else if val < 0x800 { return 2; } else if val < 0x10000 { return 3; } else { return 4; } } }