Example usage for java.lang Character highSurrogate

List of usage examples for java.lang Character highSurrogate

Introduction

In this page you can find the example usage for java.lang Character highSurrogate.

Prototype

public static char highSurrogate(int codePoint) 

Source Link

Document

Returns the leading surrogate (a <a href="http://www.unicode.org/glossary/#high_surrogate_code_unit"> high surrogate code unit</a>) of the <a href="http://www.unicode.org/glossary/#surrogate_pair"> surrogate pair</a> representing the specified supplementary character (Unicode code point) in the UTF-16 encoding.

Usage

From source file:Main.java

public static void main(String[] args) {
    int cp1 = 0x008f, cp2 = 0x0123;

    System.out.println(Character.highSurrogate(cp1));
    System.out.println(Character.highSurrogate(cp2));
}

From source file:org.codelibs.fess.crawler.util.UnsafeStringBuilder.java

public StrBuilder appendCodePoint(int codePoint) {
    if (Character.isBmpCodePoint(codePoint)) {
        append((char) codePoint);
    } else if (Character.isValidCodePoint(codePoint)) {
        append(Character.highSurrogate(codePoint));
        append(Character.lowSurrogate(codePoint));
    } else {//  w ww .  j a v a 2  s  .c  om
        throw new IllegalArgumentException();
    }
    return this;
}

From source file:org.eclipse.rdf4j.rio.turtle.TurtleParser.java

/**
 * Appends the characters from codepoint into the string builder. This is
 * the same as Character#toChars but prevents the additional char array
 * garbage for BMP codepoints.// ww w.j  a va2 s  .  c  o  m
 * 
 * @param dst
 *            the destination in which to append the characters
 * @param codePoint
 *            the codepoint to be appended
 */
private static void appendCodepoint(StringBuilder dst, int codePoint) {
    if (Character.isBmpCodePoint(codePoint)) {
        dst.append((char) codePoint);
    } else if (Character.isValidCodePoint(codePoint)) {
        dst.append(Character.highSurrogate(codePoint));
        dst.append(Character.lowSurrogate(codePoint));
    } else {
        throw new IllegalArgumentException("Invalid codepoint " + codePoint);
    }
}