|
|
|
@ -31,15 +31,17 @@ public object ModifiedUtf8Charset : Charset("ModifiedUtf8", null) { |
|
|
|
|
return CoderResult.OVERFLOW |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (len == 1) { |
|
|
|
|
output.put(char.toByte()) |
|
|
|
|
} else if (len == 2) { |
|
|
|
|
output.put((0xC0 or ((char.toInt() shr 6) and 0x1F)).toByte()) |
|
|
|
|
output.put((0x80 or (char.toInt() and 0x3F)).toByte()) |
|
|
|
|
} else { |
|
|
|
|
output.put((0xE0 or ((char.toInt() shr 12) and 0x1F)).toByte()) |
|
|
|
|
output.put((0x80 or ((char.toInt() shr 6) and 0x1F)).toByte()) |
|
|
|
|
output.put((0x80 or (char.toInt() and 0x3F)).toByte()) |
|
|
|
|
when (len) { |
|
|
|
|
1 -> output.put(char.toByte()) |
|
|
|
|
2 -> { |
|
|
|
|
output.put((0xC0 or ((char.toInt() shr 6) and 0x1F)).toByte()) |
|
|
|
|
output.put((0x80 or (char.toInt() and 0x3F)).toByte()) |
|
|
|
|
} |
|
|
|
|
else -> { |
|
|
|
|
output.put((0xE0 or ((char.toInt() shr 12) and 0x1F)).toByte()) |
|
|
|
|
output.put((0x80 or ((char.toInt() shr 6) and 0x1F)).toByte()) |
|
|
|
|
output.put((0x80 or (char.toInt() and 0x3F)).toByte()) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|