• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2006 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.text;
18 
19 /**
20  * AndroidCharacter exposes some character properties that used to be not
21  * easily accessed from java.lang.Character, but are now available in ICU.
22  * @deprecated Use various methods from {@link android.icu.lang.UCharacter}, instead.
23  */
24 @Deprecated
25 @android.ravenwood.annotation.RavenwoodKeepWholeClass
26 public class AndroidCharacter
27 {
28     public static final int EAST_ASIAN_WIDTH_NEUTRAL = 0;
29     public static final int EAST_ASIAN_WIDTH_AMBIGUOUS = 1;
30     public static final int EAST_ASIAN_WIDTH_HALF_WIDTH = 2;
31     public static final int EAST_ASIAN_WIDTH_FULL_WIDTH = 3;
32     public static final int EAST_ASIAN_WIDTH_NARROW = 4;
33     public static final int EAST_ASIAN_WIDTH_WIDE = 5;
34 
35     /**
36      * Fill in the first <code>count</code> bytes of <code>dest</code> with the
37      * directionalities from the first <code>count</code> chars of <code>src</code>.
38      * This is just like Character.getDirectionality() except it is a
39      * batch operation.
40      */
getDirectionalities(char[] src, byte[] dest, int count)41     public native static void getDirectionalities(char[] src, byte[] dest,
42                                                   int count);
43 
44     /**
45      * Calculate the East Asian Width of a character according to
46      * <a href="http://unicode.org/reports/tr11/">Unicode TR#11</a>. The return
47      * will be one of {@link #EAST_ASIAN_WIDTH_NEUTRAL},
48      * {@link #EAST_ASIAN_WIDTH_AMBIGUOUS}, {@link #EAST_ASIAN_WIDTH_HALF_WIDTH},
49      * {@link #EAST_ASIAN_WIDTH_FULL_WIDTH}, {@link #EAST_ASIAN_WIDTH_NARROW},
50      * or {@link #EAST_ASIAN_WIDTH_WIDE}.
51      *
52      * @param input the character to measure
53      * @return the East Asian Width for input
54      */
getEastAsianWidth(char input)55     public native static int getEastAsianWidth(char input);
56 
57     /**
58      * Fill the first <code>count</code> bytes of <code>dest</code> with the
59      * East Asian Width from <code>count</code> chars of <code>src</code>
60      * starting at <code>start</code>. East Asian Width is calculated based on
61      * <a href="http://unicode.org/reports/tr11/">Unicode TR#11</a>. Each entry
62      * in <code>dest</code> will be one of {@link #EAST_ASIAN_WIDTH_NEUTRAL},
63      * {@link #EAST_ASIAN_WIDTH_AMBIGUOUS}, {@link #EAST_ASIAN_WIDTH_HALF_WIDTH},
64      * {@link #EAST_ASIAN_WIDTH_FULL_WIDTH}, {@link #EAST_ASIAN_WIDTH_NARROW},
65      * or {@link #EAST_ASIAN_WIDTH_WIDE}.
66      *
67      * @param src character array of input to measure
68      * @param start first character in array to measure
69      * @param count maximum number of characters to measure
70      * @param dest byte array of results for each character in src
71      */
getEastAsianWidths(char[] src, int start, int count, byte[] dest)72     public native static void getEastAsianWidths(char[] src, int start,
73                                                  int count, byte[] dest);
74 
75     /**
76      * Replace the specified slice of <code>text</code> with the chars'
77      * right-to-left mirrors (if any), returning true if any
78      * replacements were made.
79      *
80      * @param text array of characters to apply mirror operation
81      * @param start first character in array to mirror
82      * @param count maximum number of characters to mirror
83      * @return true if replacements were made
84      */
mirror(char[] text, int start, int count)85     public native static boolean mirror(char[] text, int start, int count);
86 
87     /**
88      * Return the right-to-left mirror (or the original char if none)
89      * of the specified char.
90      */
getMirror(char ch)91     public native static char getMirror(char ch);
92 }
93