Package oracle.i18n.text
Class OraUnicodeProperty
- java.lang.Object
-
- oracle.i18n.text.OraUnicodeProperty
-
- All Implemented Interfaces:
Serializable
public class OraUnicodeProperty extends Object implements Serializable
ThisOraUnicodeProperty
class is used to access Unicode character property. Currently only display width information is provided.- Since:
- Oracle 11
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getDisplayWidth(int codepoint, String charSet, boolean isReplacementOn)
Get the display width of a Unicodecodepoint
.int
getDisplayWidth(String str, String charSet, boolean isReplacementOn)
Get the display width of a Unicode stringstr
.static OraUnicodeProperty
getInstance()
Get an OraUnicodeProperty instance.
-
-
-
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 Unicodecodepoint
. 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 setcharSet
is used to resolve their display width. In other words, if the display width of the Unicodecodepoint
is ambiguous, then return its display width in the target character setcharSet
. 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 codepointcharSet
- a target JAVA character set nameisReplacementOn
- 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 stringstr
. 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 setcharSet
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 stringcharSet
- a target JAVA character set nameisReplacementOn
- 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.
-
-