org.apache.fop.complexscripts.util

## Class UTF32

- java.lang.Object
- - org.apache.fop.complexscripts.util.UTF32

-     public final class UTF32
      extends Object

  UTF32 related utilities.

  This work was originally authored by Glenn Adams (gadams@apache.org).

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static String` | `fromUTF32(Integer[] sa)` Convert a Unicode scalar array (UTF-32) a Java string (UTF-16).
    `static Integer[]` | `toUTF32(String s, int substitution, boolean errorOnSubstitution)` Convert Java string (UTF-16) to a Unicode scalar array (UTF-32).

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### toUTF32

          public static Integer[] toUTF32(String s,
                                          int substitution,
                                          boolean errorOnSubstitution)
                                   throws IllegalArgumentException

      Convert Java string (UTF-16) to a Unicode scalar array (UTF-32). Note that if there are any non-BMP encoded characters present in the input, then the number of entries in the output array will be less than the number of elements in the input string. Any
      Parameters:
        `s` - input string
        `substitution` - value to substitute for ill-formed surrogate
        `errorOnSubstitution` - throw runtime exception (IllegalArgumentException) in case this argument is true and a substitution would be attempted
      Returns:
        output scalar array
      Throws:
        `IllegalArgumentException` - if substitution required and errorOnSubstitution is not false

    - #### fromUTF32

          public static String fromUTF32(Integer[] sa)
                                  throws IllegalArgumentException

      Convert a Unicode scalar array (UTF-32) a Java string (UTF-16).
      Parameters:
        `sa` - input scalar array
      Returns:
        output (UTF-16) string
      Throws:
        `IllegalArgumentException` - if an input scalar value is illegal, e.g., a surrogate or out of range

Copyright © 2025 Apache Software Foundation. All rights reserved.