safeArrayWriteUtf8() — netty Function Reference
Architecture documentation for the safeArrayWriteUtf8() function in ByteBufUtil.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 49189550_50ad_9fcd_fcb2_897fe322cf6c["safeArrayWriteUtf8()"] 920454f6_25f6_4a9b_3d32_9684c3e11f6c["ByteBufUtil"] 49189550_50ad_9fcd_fcb2_897fe322cf6c -->|defined in| 920454f6_25f6_4a9b_3d32_9684c3e11f6c 1179b53a_e196_1505_4b75_0d4181586259["writeUtf8()"] 1179b53a_e196_1505_4b75_0d4181586259 -->|calls| 49189550_50ad_9fcd_fcb2_897fe322cf6c style 49189550_50ad_9fcd_fcb2_897fe322cf6c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
buffer/src/main/java/io/netty/buffer/ByteBufUtil.java lines 1052–1092
private static int safeArrayWriteUtf8(byte[] buffer, int writerIndex, CharSequence seq, int start, int end) {
int oldWriterIndex = writerIndex;
for (int i = start; i < end; i++) {
char c = seq.charAt(i);
if (c < 0x80) {
buffer[writerIndex++] = (byte) c;
} else if (c < 0x800) {
buffer[writerIndex++] = (byte) (0xc0 | (c >> 6));
buffer[writerIndex++] = (byte) (0x80 | (c & 0x3f));
} else if (isSurrogate(c)) {
if (!Character.isHighSurrogate(c)) {
buffer[writerIndex++] = WRITE_UTF_UNKNOWN;
continue;
}
// Surrogate Pair consumes 2 characters.
if (++i == end) {
buffer[writerIndex++] = WRITE_UTF_UNKNOWN;
break;
}
char c2 = seq.charAt(i);
// Extra method is copied here to NOT allow inlining of writeUtf8
// and increase the chance to inline CharSequence::charAt instead
if (!Character.isLowSurrogate(c2)) {
buffer[writerIndex++] = WRITE_UTF_UNKNOWN;
buffer[writerIndex++] = (byte) (Character.isHighSurrogate(c2)? WRITE_UTF_UNKNOWN : c2);
} else {
int codePoint = Character.toCodePoint(c, c2);
// See https://www.unicode.org/versions/Unicode7.0.0/ch03.pdf#G2630.
buffer[writerIndex++] = (byte) (0xf0 | (codePoint >> 18));
buffer[writerIndex++] = (byte) (0x80 | ((codePoint >> 12) & 0x3f));
buffer[writerIndex++] = (byte) (0x80 | ((codePoint >> 6) & 0x3f));
buffer[writerIndex++] = (byte) (0x80 | (codePoint & 0x3f));
}
} else {
buffer[writerIndex++] = (byte) (0xe0 | (c >> 12));
buffer[writerIndex++] = (byte) (0x80 | ((c >> 6) & 0x3f));
buffer[writerIndex++] = (byte) (0x80 | (c & 0x3f));
}
}
return writerIndex - oldWriterIndex;
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does safeArrayWriteUtf8() do?
safeArrayWriteUtf8() is a function in the netty codebase, defined in buffer/src/main/java/io/netty/buffer/ByteBufUtil.java.
Where is safeArrayWriteUtf8() defined?
safeArrayWriteUtf8() is defined in buffer/src/main/java/io/netty/buffer/ByteBufUtil.java at line 1052.
What calls safeArrayWriteUtf8()?
safeArrayWriteUtf8() is called by 1 function(s): writeUtf8.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free