01: package org.kohsuke.rngom.util;
02:
03: public abstract class Utf16 {
04: // 110110XX XXXXXX 110111XX XXXXXX
05: static public boolean isSurrogate(char c) {
06: return (c & 0xF800) == 0xD800;
07: }
08:
09: static public boolean isSurrogate1(char c) {
10: return (c & 0xFC00) == 0xD800;
11: }
12:
13: static public boolean isSurrogate2(char c) {
14: return (c & 0xFC00) == 0xDC00;
15: }
16:
17: static public int scalarValue(char c1, char c2) {
18: return (((c1 & 0x3FF) << 10) | (c2 & 0x3FF)) + 0x10000;
19: }
20:
21: static public char surrogate1(int c) {
22: return (char) (((c - 0x10000) >> 10) | 0xD800);
23: }
24:
25: static public char surrogate2(int c) {
26: return (char) (((c - 0x10000) & 0x3FF) | 0xDC00);
27: }
28: }
|