public class Base16Codec extends Object implements Encoder<byte[],char[]>, Decoder<CharSequence,byte[]>, Serializable
Modifier and Type | Field and Description |
---|---|
static Base16Codec |
CODEC_LOWER
编码解码器:小写
|
static Base16Codec |
CODEC_UPPER
编码解码器:大写
|
Constructor and Description |
---|
Base16Codec(boolean lowerCase)
构造
|
Modifier and Type | Method and Description |
---|---|
void |
appendHex(StringBuilder builder,
byte b)
将byte值转为16进制并添加到
StringBuilder 中 |
byte[] |
decode(CharSequence encoded)
执行解码
|
char[] |
encode(byte[] data)
执行编码
|
char |
hexDigit(int b)
将byte值转为16进制
|
String |
toUnicodeHex(char ch)
将指定char值转换为Unicode字符串形式,常用于特殊字符(例如汉字)转Unicode形式
转换的字符串如果u后不足4位,则前面用0填充,例如: 你 =》\u4f60 |
public static final Base16Codec CODEC_LOWER
public static final Base16Codec CODEC_UPPER
public Base16Codec(boolean lowerCase)
lowerCase
- 是否小写public char[] encode(byte[] data)
Encoder
public byte[] decode(CharSequence encoded)
Decoder
decode
in interface Decoder<CharSequence,byte[]>
encoded
- 被解码的数据public String toUnicodeHex(char ch)
你 =》\u4f60
ch
- char值public void appendHex(StringBuilder builder, byte b)
StringBuilder
中builder
- StringBuilder
b
- bytepublic char hexDigit(int b)
b
- byteCopyright © 2025. All rights reserved.