void (@NotNull CharSequence value, @NotNull ByteBuf buffer) { int length = value.length(); buffer.ensureWritable(length * 2); buffer.writeByte('"'); int last = 0; for (int i = 0; i < length; i++) { char c = value.charAt(i); String replacement; if (c < 128) { replacement = REPLACEMENT_CHARS[c]; if (replacement == null) { continue; } } else if (c == '\u2028') { replacement = "\\u2028"; } else if (c == '\u2029') { replacement = "\\u2029"; } else { continue; } if (last < i) { ByteBufUtilEx.writeUtf8(buffer, value, last, i); } ByteBufUtil.writeAscii(buffer, replacement); last = i + 1; } if (last < length) { ByteBufUtilEx.writeUtf8(buffer, value, last, length); } buffer.writeByte('"'); }