Package com.google.protobuf
Class Utf8.DecodeUtil
java.lang.Object
com.google.protobuf.Utf8.DecodeUtil
- Enclosing class:
Utf8
Utility methods for decoding bytes into
String
. Callers are responsible for extracting
bytes (possibly using Unsafe methods), and checking remaining bytes. All other UTF-8 validity
checks and codepoint conversion happen in this class.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static void
handleFourBytes
(byte byte1, byte byte2, byte byte3, byte byte4, char[] resultArr, int resultPos) private static void
handleOneByte
(byte byte1, char[] resultArr, int resultPos) private static void
handleThreeBytes
(byte byte1, byte byte2, byte byte3, char[] resultArr, int resultPos) private static void
handleTwoBytes
(byte byte1, byte byte2, char[] resultArr, int resultPos) private static char
highSurrogate
(int codePoint) private static boolean
isNotTrailingByte
(byte b) Returns whether the byte is not a valid continuation of the form '10XXXXXX'.private static boolean
isOneByte
(byte b) Returns whether this is a single-byte codepoint (i.e., ASCII) with the form '0XXXXXXX'.private static boolean
isThreeBytes
(byte b) Returns whether this is a three-byte codepoint with the form '110XXXXX' iffisOneByte(byte)
andisTwoBytes(byte)
are false.private static boolean
isTwoBytes
(byte b) Returns whether this is a two-byte codepoint with the form '10XXXXXX' iffisOneByte(byte)
is false.private static char
lowSurrogate
(int codePoint) private static int
trailingByteValue
(byte b) Returns the actual value of the trailing byte (removes the prefix '10') for composition.
-
Constructor Details
-
DecodeUtil
private DecodeUtil()
-
-
Method Details
-
isOneByte
private static boolean isOneByte(byte b) Returns whether this is a single-byte codepoint (i.e., ASCII) with the form '0XXXXXXX'. -
isTwoBytes
private static boolean isTwoBytes(byte b) Returns whether this is a two-byte codepoint with the form '10XXXXXX' iffisOneByte(byte)
is false. This private method works in the limited use in this class where this method is only called whenisOneByte(byte)
has already returned false. It is not suitable for general or public use. -
isThreeBytes
private static boolean isThreeBytes(byte b) Returns whether this is a three-byte codepoint with the form '110XXXXX' iffisOneByte(byte)
andisTwoBytes(byte)
are false. This private method works in the limited use in this class where this method is only called whenisOneByte(byte)
anisTwoBytes(byte)
have already returned false. It is not suitable for general or public use. -
handleOneByte
private static void handleOneByte(byte byte1, char[] resultArr, int resultPos) -
handleTwoBytes
private static void handleTwoBytes(byte byte1, byte byte2, char[] resultArr, int resultPos) throws InvalidProtocolBufferException - Throws:
InvalidProtocolBufferException
-
handleThreeBytes
private static void handleThreeBytes(byte byte1, byte byte2, byte byte3, char[] resultArr, int resultPos) throws InvalidProtocolBufferException - Throws:
InvalidProtocolBufferException
-
handleFourBytes
private static void handleFourBytes(byte byte1, byte byte2, byte byte3, byte byte4, char[] resultArr, int resultPos) throws InvalidProtocolBufferException - Throws:
InvalidProtocolBufferException
-
isNotTrailingByte
private static boolean isNotTrailingByte(byte b) Returns whether the byte is not a valid continuation of the form '10XXXXXX'. -
trailingByteValue
private static int trailingByteValue(byte b) Returns the actual value of the trailing byte (removes the prefix '10') for composition. -
highSurrogate
private static char highSurrogate(int codePoint) -
lowSurrogate
private static char lowSurrogate(int codePoint)
-