Example usage for java.lang Character MAX_SURROGATE

List of usage examples for java.lang Character MAX_SURROGATE

Introduction

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

Prototype

char MAX_SURROGATE

To view the source code for java.lang Character MAX_SURROGATE.

Click Source Link

Document

The maximum value of a Unicode surrogate code unit in the UTF-16 encoding, constant '\u005CuDFFF' .

Usage

From source file:Main.java

public static void main(String[] args) {
    System.out.println("Character.MAX_SURROGATE:" + (int) Character.MAX_SURROGATE);
}

From source file:Main.java

public static int[] generateCodePointSet(final int codePointSetSize, final Random random) {
    final int[] codePointSet = new int[codePointSetSize];
    for (int i = codePointSet.length - 1; i >= 0;) {
        final int r = Math.abs(random.nextInt());
        if (r < 0)
            continue;
        // Don't insert 0~0x20, but insert any other code point.
        // Code points are in the range 0~0x10FFFF.
        final int candidateCodePoint = 0x20 + r % (Character.MAX_CODE_POINT - 0x20);
        // Code points between MIN_ and MAX_SURROGATE are not valid on their own.
        if (candidateCodePoint >= Character.MIN_SURROGATE && candidateCodePoint <= Character.MAX_SURROGATE)
            continue;
        codePointSet[i] = candidateCodePoint;
        --i;/* w  ww . j  a v a  2  s  .  c o m*/
    }
    return codePointSet;
}

From source file:Main.java

@Nonnull
public static int[] generateCodePointSet(final int codePointSetSize, @Nonnull final Random random) {
    final int[] codePointSet = new int[codePointSetSize];
    for (int i = codePointSet.length - 1; i >= 0;) {
        final int r = Math.abs(random.nextInt());
        if (r < 0) {
            continue;
        }// w  w  w . ja va2  s .  com
        // Don't insert 0~0x20, but insert any other code point.
        // Code points are in the range 0~0x10FFFF.
        final int candidateCodePoint = 0x20 + r % (Character.MAX_CODE_POINT - 0x20);
        // Code points between MIN_ and MAX_SURROGATE are not valid on their own.
        if (candidateCodePoint >= Character.MIN_SURROGATE && candidateCodePoint <= Character.MAX_SURROGATE) {
            continue;
        }
        codePointSet[i] = candidateCodePoint;
        --i;
    }
    return codePointSet;
}