All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.thaiopensource.util.Utf16 Maven / Gradle / Ivy

Go to download

Jing is a validator for RELAX NG and other schema languages. This project was taken from http://code.google.com/p/jing-trang and mavenized for inclusion in the Wicket Stuff HTML Validator. The code was taken from the 20091111 release.

There is a newer version: 1.11
Show newest version
package com.thaiopensource.util;

public abstract class Utf16 {
  // 110110XX XXXXXX 110111XX XXXXXX
  static public boolean isSurrogate(char c) {
    return (c & 0xF800) == 0xD800;
  }
  static public boolean isSurrogate(int c) {
    return c >= 0 && c <= 0xFFFF && isSurrogate((char)c);
  }
  static public boolean isSurrogate1(char c) {
    return (c & 0xFC00) == 0xD800;
  }
  static public boolean isSurrogate2(char c) {
    return (c & 0xFC00) == 0xDC00;
  }
  static public int scalarValue(char c1, char c2) {
    return (((c1 & 0x3FF) << 10) | (c2 & 0x3FF)) + 0x10000;
  }
  static public char surrogate1(int c) {
    return (char)(((c - 0x10000) >> 10) | 0xD800);
  }
  static public char surrogate2(int c) {
    return (char)(((c - 0x10000) & 0x3FF) | 0xDC00);
  }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy