Here you can find the source of appendSurrogate(ByteBuffer bb, char c)
%Uxxxx
to the given byte buffer.
Parameter | Description |
---|---|
bb | The byte buffer to write to. |
c | The character to write. |
static void appendSurrogate(ByteBuffer bb, char c)
//package com.java2s; //License from project: Apache License import java.nio.ByteBuffer; public class Main { /**//from w w w . ja v a2 s .co m * The hexadecimal digits <code>0,...,9,A,...,F</code> encoded as * ASCII bytes. */ private static final byte[] HEX_DIGITS = new byte[] { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 }; /** * Append <code>%Uxxxx</code> to the given byte buffer. * The caller must assure, that <code>bb.remaining()>=6</code>. * * @param bb The byte buffer to write to. * @param c The character to write. */ static void appendSurrogate(ByteBuffer bb, char c) { bb.put((byte) '%'); bb.put((byte) 'U'); bb.put(HEX_DIGITS[(c >> 12) & 0x0f]); bb.put(HEX_DIGITS[(c >> 8) & 0x0f]); bb.put(HEX_DIGITS[(c >> 4) & 0x0f]); bb.put(HEX_DIGITS[c & 0x0f]); } }