Example usage for io.netty.buffer ByteBufUtil utf8Bytes

List of usage examples for io.netty.buffer ByteBufUtil utf8Bytes

Introduction

In this page you can find the example usage for io.netty.buffer ByteBufUtil utf8Bytes.

Prototype

public static int utf8Bytes(final CharSequence seq) 

Source Link

Document

Returns the exact bytes length of UTF8 character sequence.

Usage

From source file:org.springframework.cloud.gateway.rsocket.support.Metadata.java

License:Apache License

private static void encodeString(ByteBuf byteBuf, String s) {
    int length = NumberUtils.requireUnsignedByte(ByteBufUtil.utf8Bytes(s));
    byteBuf.writeByte(length);//from   w ww  .  ja  v a 2  s .  c  o m
    ByteBufUtil.reserveAndWriteUtf8(byteBuf, s, length);
}