Class OraUnicodeProperty

  • All Implemented Interfaces:
    Serializable

    public class OraUnicodeProperty
    extends Object
    implements Serializable
    This OraUnicodeProperty class is used to access Unicode character property. Currently only display width information is provided.
    Since:
    Oracle 11
    See Also:
    Serialized Form
    • Method Detail

      • getInstance

        public static OraUnicodeProperty getInstance()
        Get an OraUnicodeProperty instance. This class is a singleton. Two or more calls will get the same instance.
        Returns:
        an OraUnicodeProperty object
      • getDisplayWidth

        public int getDisplayWidth​(int codepoint,
                                   String charSet,
                                   boolean isReplacementOn)
                            throws SQLException,
                                   UnsupportedEncodingException
        Get the display width of a Unicode codepoint. Display width classification is based on East Asia Width definition of Unicode Standard, and display width data are from Unicode version 4.0. Ambiguous characters can be sometimes narrow and sometimes wide, and target character set charSet is used to resolve their display width. In other words, if the display width of the Unicode codepoint is ambiguous, then return its display width in the target character set charSet. If its display width is not defined in the target character set, return 1 if it is a single byte character; return 2 otherwise(a multi-byte character).
        Example:
            OraUnicodeProperty oup = OraUnicodeProperty.getInstance();
            int width = oup.getDisplayWidth(0x1121, "EUC_JP", true);
         
        Parameters:
        codepoint - a Unicode codepoint
        charSet - a target JAVA character set name
        isReplacementOn - a flag indicating whether character replacement is allowed for conversion.
        Returns:
        display width. Possible values are 0, 1, and 2.
        Throws:
        UnsupportedEncodingException - if the display width is ambiguous and the target character set name is invalid, or Oracle does not have a corresponding character set mapping, or the codepoint is an invalid surrogate.
        SQLException - if character replacement is needed for conversion but the replacement flag is off.
      • getDisplayWidth

        public int getDisplayWidth​(String str,
                                   String charSet,
                                   boolean isReplacementOn)
                            throws SQLException,
                                   UnsupportedEncodingException
        Get the display width of a Unicode string str. Display width classification is based on East Asia Width definition of Unicode Standard, and display width data are from Unicode version 4.0. Ambiguous characters can be sometimes narrow and sometimes wide, and target character set charSet is used to resolve their display width.
        Example:
            String str = "Hello, how are you?"; 
            OraUnicodeProperty oup = OraUnicodeProperty.getInstance();
            int width = oup.getDisplayWidth(str, "GBK", true);
         
        Parameters:
        str - a Unicode string
        charSet - a target JAVA character set name
        isReplacementOn - a flag indicating whether character replacement is allowed for conversion
        Returns:
        display width.
        Throws:
        UnsupportedEncodingException - if the display width is ambiguous and the target character set name is invalid or Oracle does not have a corresponding character set mapping, or the string contains any invalid unicode surrogates.
        SQLException - if character replacement is needed for conversion but the replacement flag is off.