• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 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 com.android.bluetooth.util;
18 
19 import android.util.Log;
20 import android.util.SparseIntArray;
21 
22 /**
23  * This class implements the character set mapping between the GSM SMS 7-bit alphabet specified in
24  * TS 23.038 6.2.1 and UTF-16
25  */
26 public class GsmAlphabet {
27     private static final String TAG = GsmAlphabet.class.getSimpleName();
28 
29     /**
30      * This escapes extended characters, and when present indicates that the following character
31      * should be looked up in the "extended" table.
32      *
33      * <p>gsmToChar(GSM_EXTENDED_ESCAPE) returns 0xffff
34      */
35     public static final byte GSM_EXTENDED_ESCAPE = 0x1B;
36 
37     /**
38      * User data header requires one octet for length. Count as one septet, because all combinations
39      * of header elements below will have at least one free bit when padding to the nearest septet
40      * boundary.
41      */
42     public static final int UDH_SEPTET_COST_LENGTH = 1;
43 
44     /**
45      * Using a non-default language locking shift table OR single shift table requires a user data
46      * header of 3 octets, or 4 septets, plus UDH length.
47      */
48     public static final int UDH_SEPTET_COST_ONE_SHIFT_TABLE = 4;
49 
50     /**
51      * Using a non-default language locking shift table AND single shift table requires a user data
52      * header of 6 octets, or 7 septets, plus UDH length.
53      */
54     public static final int UDH_SEPTET_COST_TWO_SHIFT_TABLES = 7;
55 
56     /**
57      * Multi-part messages require a user data header of 5 octets, or 6 septets, plus UDH length.
58      */
59     public static final int UDH_SEPTET_COST_CONCATENATED_MESSAGE = 6;
60 
61     /**
62      * For a specific text string, this object describes protocol properties of encoding it for
63      * transmission as message user data.
64      */
65     public static class TextEncodingDetails {
66 
TextEncodingDetails()67         public TextEncodingDetails() {}
68 
69         /** The number of SMS's required to encode the text. */
70         public int msgCount;
71 
72         /**
73          * The number of code units consumed so far, where code units are basically characters in
74          * the encoding -- for example, septets for the standard ASCII and GSM encodings, and 16
75          * bits for Unicode.
76          */
77         public int codeUnitCount;
78 
79         /** How many code units are still available without spilling into an additional message. */
80         public int codeUnitsRemaining;
81 
82         /**
83          * The encoding code unit size (specified using android.telephony.SmsMessage ENCODING_*).
84          */
85         public int codeUnitSize;
86 
87         /** The GSM national language table to use, or 0 for the default 7-bit alphabet. */
88         public int languageTable;
89 
90         /**
91          * The GSM national language shift table to use, or 0 for the default 7-bit extension table.
92          */
93         public int languageShiftTable;
94 
95         @Override
toString()96         public String toString() {
97             return "TextEncodingDetails "
98                     + "{ msgCount="
99                     + msgCount
100                     + ", codeUnitCount="
101                     + codeUnitCount
102                     + ", codeUnitsRemaining="
103                     + codeUnitsRemaining
104                     + ", codeUnitSize="
105                     + codeUnitSize
106                     + ", languageTable="
107                     + languageTable
108                     + ", languageShiftTable="
109                     + languageShiftTable
110                     + " }";
111         }
112     }
113 
114     /**
115      * Convert a GSM alphabet 7 bit packed string (SMS string) into a {@link java.lang.String}.
116      *
117      * <p>See TS 23.038 6.1.2.1 for SMS Character Packing
118      *
119      * @param pdu the raw data from the pdu
120      * @param offset the byte offset of
121      * @param lengthSeptets string length in septets, not bytes
122      * @param numPaddingBits the number of padding bits before the start of the string in the first
123      *     byte
124      * @param languageTable the 7 bit language table, or 0 for the default GSM alphabet
125      * @param shiftTable the 7 bit single shift language table, or 0 for the default GSM extension
126      *     table
127      * @return String representation or null on decoding exception
128      */
gsm7BitPackedToString( byte[] pdu, int offset, int lengthSeptets, int numPaddingBits, int languageTable, int shiftTable)129     public static String gsm7BitPackedToString(
130             byte[] pdu,
131             int offset,
132             int lengthSeptets,
133             int numPaddingBits,
134             int languageTable,
135             int shiftTable) {
136         StringBuilder ret = new StringBuilder(lengthSeptets);
137 
138         if (languageTable < 0 || languageTable > sLanguageTables.length) {
139             Log.w(TAG, "unknown language table " + languageTable + ", using default");
140             languageTable = 0;
141         }
142         if (shiftTable < 0 || shiftTable > sLanguageShiftTables.length) {
143             Log.w(TAG, "unknown single shift table " + shiftTable + ", using default");
144             shiftTable = 0;
145         }
146 
147         try {
148             boolean prevCharWasEscape = false;
149             String languageTableToChar = sLanguageTables[languageTable];
150             String shiftTableToChar = sLanguageShiftTables[shiftTable];
151 
152             if (languageTableToChar.isEmpty()) {
153                 Log.w(TAG, "no language table for code " + languageTable + ", using default");
154                 languageTableToChar = sLanguageTables[0];
155             }
156             if (shiftTableToChar.isEmpty()) {
157                 Log.w(TAG, "no single shift table for code " + shiftTable + ", using default");
158                 shiftTableToChar = sLanguageShiftTables[0];
159             }
160 
161             for (int i = 0; i < lengthSeptets; i++) {
162                 int bitOffset = (7 * i) + numPaddingBits;
163 
164                 int byteOffset = bitOffset / 8;
165                 int shift = bitOffset % 8;
166                 int gsmVal;
167 
168                 gsmVal = (0x7f & (pdu[offset + byteOffset] >> shift));
169 
170                 // if it crosses a byte boundary
171                 if (shift > 1) {
172                     // set msb bits to 0
173                     gsmVal &= 0x7f >> (shift - 1);
174 
175                     gsmVal |= 0x7f & (pdu[offset + byteOffset + 1] << (8 - shift));
176                 }
177 
178                 if (prevCharWasEscape) {
179                     if (gsmVal == GSM_EXTENDED_ESCAPE) {
180                         ret.append(' '); // display ' ' for reserved double escape sequence
181                     } else {
182                         char c = shiftTableToChar.charAt(gsmVal);
183                         if (c == ' ') {
184                             ret.append(languageTableToChar.charAt(gsmVal));
185                         } else {
186                             ret.append(c);
187                         }
188                     }
189                     prevCharWasEscape = false;
190                 } else if (gsmVal == GSM_EXTENDED_ESCAPE) {
191                     prevCharWasEscape = true;
192                 } else {
193                     ret.append(languageTableToChar.charAt(gsmVal));
194                 }
195             }
196         } catch (RuntimeException ex) {
197             Log.e(TAG, "Error GSM 7 bit packed: " + '\n' + Log.getStackTraceString(ex));
198             return null;
199         }
200 
201         return ret.toString();
202     }
203 
204     /**
205      * Convert a string into an 8-bit unpacked GSM alphabet byte array. Always uses GSM default
206      * 7-bit alphabet and extension table.
207      *
208      * @param s the string to encode
209      * @return the 8-bit GSM encoded byte array for the string
210      */
stringToGsm8BitPacked(String s)211     public static byte[] stringToGsm8BitPacked(String s) {
212         byte[] ret;
213 
214         int septets = countGsmSeptetsUsingTables(s, true, 0, 0);
215 
216         // Enough for all the septets and the length byte prefix
217         ret = new byte[septets];
218 
219         stringToGsm8BitUnpackedField(s, ret, 0, ret.length);
220 
221         return ret;
222     }
223 
224     /**
225      * Write a String into a GSM 8-bit unpacked field of Field is padded with 0xff's, string is
226      * truncated if necessary
227      *
228      * @param s the string to encode
229      * @param dest the destination byte array
230      * @param offset the starting offset for the encoded string
231      * @param length the maximum number of bytes to write
232      */
stringToGsm8BitUnpackedField(String s, byte[] dest, int offset, int length)233     public static void stringToGsm8BitUnpackedField(String s, byte[] dest, int offset, int length) {
234         int outByteIndex = offset;
235         SparseIntArray charToLanguageTable = sCharsToGsmTables[0];
236         SparseIntArray charToShiftTable = sCharsToShiftTables[0];
237 
238         // Septets are stored in byte-aligned octets
239         for (int i = 0, sz = s.length(); i < sz && (outByteIndex - offset) < length; i++) {
240             char c = s.charAt(i);
241             int v = charToLanguageTable.get(c, -1);
242             if (v == -1) {
243                 v = charToShiftTable.get(c, -1);
244                 if (v == -1) {
245                     v = charToLanguageTable.get(' ', ' '); // fall back to ASCII space
246                 } else {
247                     // make sure we can fit an escaped char
248                     if (!(outByteIndex + 1 - offset < length)) {
249                         break;
250                     }
251 
252                     dest[outByteIndex++] = GSM_EXTENDED_ESCAPE;
253                 }
254             }
255 
256             dest[outByteIndex++] = (byte) v;
257         }
258 
259         // pad with 0xff's
260         while ((outByteIndex - offset) < length) {
261             dest[outByteIndex++] = (byte) 0xff;
262         }
263     }
264 
265     /**
266      * Returns the count of 7-bit GSM alphabet characters needed to represent this string, using the
267      * specified 7-bit language table and extension table (0 for GSM default tables).
268      *
269      * @param s the Unicode string that will be encoded
270      * @param use7bitOnly allow using space in place of unencodable character if true, otherwise,
271      *     return -1 if any characters are unencodable
272      * @param languageTable the 7 bit language table, or 0 for the default GSM alphabet
273      * @param languageShiftTable the 7 bit single shift language table, or 0 for the default GSM
274      *     extension table
275      * @return the septet count for s using the specified language tables, or -1 if any characters
276      *     are unencodable and use7bitOnly is false
277      */
countGsmSeptetsUsingTables( CharSequence s, boolean use7bitOnly, int languageTable, int languageShiftTable)278     public static int countGsmSeptetsUsingTables(
279             CharSequence s, boolean use7bitOnly, int languageTable, int languageShiftTable) {
280         int count = 0;
281         int sz = s.length();
282         SparseIntArray charToLanguageTable = sCharsToGsmTables[languageTable];
283         SparseIntArray charToShiftTable = sCharsToShiftTables[languageShiftTable];
284         for (int i = 0; i < sz; i++) {
285             char c = s.charAt(i);
286             if (c == GSM_EXTENDED_ESCAPE) {
287                 Log.w(TAG, "countGsmSeptets() string contains Escape character, skipping.");
288                 continue;
289             }
290             if (charToLanguageTable.get(c, -1) != -1) {
291                 count++;
292             } else if (charToShiftTable.get(c, -1) != -1) {
293                 count += 2; // escape + shift table index
294             } else if (use7bitOnly) {
295                 count++; // encode as space
296             } else {
297                 return -1; // caller must check for this case
298             }
299         }
300         return count;
301     }
302 
303     /** Reverse mapping from Unicode characters to indexes into language tables. */
304     private static final SparseIntArray[] sCharsToGsmTables;
305 
306     /** Reverse mapping from Unicode characters to indexes into language shift tables. */
307     private static final SparseIntArray[] sCharsToShiftTables;
308 
309     /**
310      * GSM default 7 bit alphabet plus national language locking shift character tables. Comment
311      * lines above strings indicate the lower four bits of the table position.
312      */
313     private static final String[] sLanguageTables = {
314         /* 3GPP TS 23.038 V9.1.1 section 6.2.1 - GSM 7 bit Default Alphabet
315         01.....23.....4.....5.....6.....7.....8.....9.....A.B.....C.....D.E.....F.....0.....1 */
316         "@\u00a3$\u00a5\u00e8\u00e9\u00f9\u00ec\u00f2\u00c7\n\u00d8\u00f8\r\u00c5\u00e5\u0394_"
317                 // 2.....3.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E.....
318                 + "\u03a6\u0393\u039b\u03a9\u03a0\u03a8\u03a3\u0398\u039e\uffff\u00c6\u00e6\u00df"
319                 // F.....012.34.....56789ABCDEF0123456789ABCDEF0.....123456789ABCDEF0123456789A
320                 + "\u00c9 !\"#\u00a4%&'()*+,-./0123456789:;<=>?\u00a1ABCDEFGHIJKLMNOPQRSTUVWXYZ"
321                 // B.....C.....D.....E.....F.....0.....123456789ABCDEF0123456789AB.....C.....D.....
322                 + "\u00c4\u00d6\u00d1\u00dc\u00a7\u00bfabcdefghijklmnopqrstuvwxyz\u00e4\u00f6\u00f1"
323                 // E.....F.....
324                 + "\u00fc\u00e0",
325 
326         /* A.3.1 Turkish National Language Locking Shift Table
327         01.....23.....4.....5.....6.....7.....8.....9.....A.B.....C.....D.E.....F.....0.....1 */
328         "@\u00a3$\u00a5\u20ac\u00e9\u00f9\u0131\u00f2\u00c7\n\u011e\u011f\r\u00c5\u00e5\u0394_"
329                 // 2.....3.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E.....
330                 + "\u03a6\u0393\u039b\u03a9\u03a0\u03a8\u03a3\u0398\u039e\uffff\u015e\u015f\u00df"
331                 // F.....012.34.....56789ABCDEF0123456789ABCDEF0.....123456789ABCDEF0123456789A
332                 + "\u00c9 !\"#\u00a4%&'()*+,-./0123456789:;<=>?\u0130ABCDEFGHIJKLMNOPQRSTUVWXYZ"
333                 // B.....C.....D.....E.....F.....0.....123456789ABCDEF0123456789AB.....C.....D.....
334                 + "\u00c4\u00d6\u00d1\u00dc\u00a7\u00e7abcdefghijklmnopqrstuvwxyz\u00e4\u00f6\u00f1"
335                 // E.....F.....
336                 + "\u00fc\u00e0",
337 
338         /* A.3.2 Void (no locking shift table for Spanish) */
339         "",
340 
341         /* A.3.3 Portuguese National Language Locking Shift Table
342         01.....23.....4.....5.....6.....7.....8.....9.....A.B.....C.....D.E.....F.....0.....1 */
343         "@\u00a3$\u00a5\u00ea\u00e9\u00fa\u00ed\u00f3\u00e7\n\u00d4\u00f4\r\u00c1\u00e1\u0394_"
344                 // 2.....3.....4.....5.....67.8.....9.....AB.....C.....D.....E.....F.....012.34.....
345                 + "\u00aa\u00c7\u00c0\u221e^\\\u20ac\u00d3|\uffff\u00c2\u00e2\u00ca\u00c9"
346                 + " !\"#\u00ba"
347                 // 56789ABCDEF0123456789ABCDEF0.....123456789ABCDEF0123456789AB.....C.....D.....E.....
348                 + "%&'()*+,-./0123456789:;<=>?\u00cdABCDEFGHIJKLMNOPQRSTUVWXYZ\u00c3\u00d5\u00da\u00dc"
349                 // F.....0123456789ABCDEF0123456789AB.....C.....DE.....F.....
350                 + "\u00a7~abcdefghijklmnopqrstuvwxyz\u00e3\u00f5`\u00fc\u00e0",
351 
352         /* A.3.4 Bengali National Language Locking Shift Table
353         0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.B.....CD.EF.....0..... */
354         "\u0981\u0982\u0983\u0985\u0986\u0987\u0988\u0989\u098a\u098b\n\u098c \r \u098f\u0990"
355                 // 123.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E.....F.....
356                 + "  \u0993\u0994\u0995\u0996\u0997\u0998\u0999\u099a\uffff\u099b\u099c\u099d\u099e"
357                 // 012.....3.....4.....5.....6.....7.....89A.....B.....CD.....EF.....0123456789ABC
358                 + " !\u099f\u09a0\u09a1\u09a2\u09a3\u09a4)(\u09a5\u09a6,\u09a7.\u09a80123456789:; "
359                 // D.....E.....F0.....1.....2.....3.....4.....56.....789A.....B.....C.....D.....
360                 + "\u09aa\u09ab?\u09ac\u09ad\u09ae\u09af\u09b0 \u09b2   \u09b6\u09b7\u09b8\u09b9"
361                 // E.....F.....0.....1.....2.....3.....4.....5.....6.....789.....A.....BCD.....E.....
362                 + "\u09bc\u09bd\u09be\u09bf\u09c0\u09c1\u09c2\u09c3\u09c4  \u09c7\u09c8 "
363                 + " \u09cb\u09cc"
364                 // F.....0.....123456789ABCDEF0123456789AB.....C.....D.....E.....F.....
365                 + "\u09cd\u09ceabcdefghijklmnopqrstuvwxyz\u09d7\u09dc\u09dd\u09f0\u09f1",
366 
367         /* A.3.5 Gujarati National Language Locking Shift Table
368         0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.B.....C.....D.EF.....0.....*/
369         "\u0a81\u0a82\u0a83\u0a85\u0a86\u0a87\u0a88\u0a89\u0a8a\u0a8b\n\u0a8c\u0a8d\r \u0a8f\u0a90"
370                 // 1.....23.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E.....
371                 + "\u0a91 \u0a93\u0a94\u0a95\u0a96\u0a97\u0a98\u0a99\u0a9a\uffff\u0a9b\u0a9c\u0a9d"
372                 // F.....012.....3.....4.....5.....6.....7.....89A.....B.....CD.....EF.....0123456789AB
373                 + "\u0a9e"
374                 + " !\u0a9f\u0aa0\u0aa1\u0aa2\u0aa3\u0aa4)(\u0aa5\u0aa6,\u0aa7.\u0aa80123456789:;"
375                 // CD.....E.....F0.....1.....2.....3.....4.....56.....7.....89.....A.....B.....C.....
376                 + " \u0aaa\u0aab?\u0aac\u0aad\u0aae\u0aaf\u0ab0 \u0ab2\u0ab3"
377                 + " \u0ab5\u0ab6\u0ab7\u0ab8"
378                 // D.....E.....F.....0.....1.....2.....3.....4.....5.....6.....7.....89.....A.....
379                 + "\u0ab9\u0abc\u0abd\u0abe\u0abf\u0ac0\u0ac1\u0ac2\u0ac3\u0ac4\u0ac5 \u0ac7\u0ac8"
380                 // B.....CD.....E.....F.....0.....123456789ABCDEF0123456789AB.....C.....D.....E.....
381                 + "\u0ac9"
382                 + " \u0acb\u0acc\u0acd\u0ad0abcdefghijklmnopqrstuvwxyz\u0ae0\u0ae1\u0ae2\u0ae3"
383                 // F.....
384                 + "\u0af1",
385 
386         /* A.3.6 Hindi National Language Locking Shift Table
387         0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.B.....C.....D.E.....F.....*/
388         "\u0901\u0902\u0903\u0905\u0906\u0907\u0908\u0909\u090a\u090b\n\u090c\u090d\r\u090e\u090f"
389                 // 0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....
390                 + "\u0910\u0911\u0912\u0913\u0914\u0915\u0916\u0917\u0918\u0919\u091a\uffff\u091b\u091c"
391                 // E.....F.....012.....3.....4.....5.....6.....7.....89A.....B.....CD.....EF.....012345
392                 + "\u091d\u091e"
393                 + " !\u091f\u0920\u0921\u0922\u0923\u0924)(\u0925\u0926,\u0927.\u0928012345"
394                 // 6789ABC.....D.....E.....F0.....1.....2.....3.....4.....5.....6.....7.....8.....
395                 + "6789:;\u0929\u092a\u092b?\u092c\u092d\u092e\u092f\u0930\u0931\u0932\u0933\u0934"
396                 // 9.....A.....B.....C.....D.....E.....F.....0.....1.....2.....3.....4.....5.....6.....
397                 + "\u0935\u0936\u0937\u0938\u0939\u093c\u093d\u093e\u093f\u0940\u0941\u0942\u0943\u0944"
398                 // 7.....8.....9.....A.....B.....C.....D.....E.....F.....0.....123456789ABCDEF012345678
399                 + "\u0945\u0946\u0947\u0948\u0949\u094a\u094b\u094c\u094d\u0950abcdefghijklmnopqrstuvwx"
400                 // 9AB.....C.....D.....E.....F.....
401                 + "yz\u0972\u097b\u097c\u097e\u097f",
402 
403         /* A.3.7 Kannada National Language Locking Shift Table
404           NOTE: TS 23.038 V9.1.1 shows code 0x24 as \u0caa, corrected to \u0ca1 (typo)
405         01.....2.....3.....4.....5.....6.....7.....8.....9.....A.B.....CD.E.....F.....0.....1 */
406         " \u0c82\u0c83\u0c85\u0c86\u0c87\u0c88\u0c89\u0c8a\u0c8b\n\u0c8c \r\u0c8e\u0c8f\u0c90 "
407                 // 2.....3.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E.....F.....
408                 + "\u0c92\u0c93\u0c94\u0c95\u0c96\u0c97\u0c98\u0c99\u0c9a\uffff\u0c9b\u0c9c\u0c9d\u0c9e"
409                 // 012.....3.....4.....5.....6.....7.....89A.....B.....CD.....EF.....0123456789ABC
410                 + " !\u0c9f\u0ca0\u0ca1\u0ca2\u0ca3\u0ca4)(\u0ca5\u0ca6,\u0ca7.\u0ca80123456789:; "
411                 // D.....E.....F0.....1.....2.....3.....4.....5.....6.....7.....89.....A.....B.....
412                 + "\u0caa\u0cab?\u0cac\u0cad\u0cae\u0caf\u0cb0\u0cb1\u0cb2\u0cb3 \u0cb5\u0cb6\u0cb7"
413                 // C.....D.....E.....F.....0.....1.....2.....3.....4.....5.....6.....78.....9.....
414                 + "\u0cb8\u0cb9\u0cbc\u0cbd\u0cbe\u0cbf\u0cc0\u0cc1\u0cc2\u0cc3\u0cc4 \u0cc6\u0cc7"
415                 // A.....BC.....D.....E.....F.....0.....123456789ABCDEF0123456789AB.....C.....D.....
416                 + "\u0cc8"
417                 + " \u0cca\u0ccb\u0ccc\u0ccd\u0cd5abcdefghijklmnopqrstuvwxyz\u0cd6\u0ce0\u0ce1"
418                 // E.....F.....
419                 + "\u0ce2\u0ce3",
420 
421         /* A.3.8 Malayalam National Language Locking Shift Table
422         01.....2.....3.....4.....5.....6.....7.....8.....9.....A.B.....CD.E.....F.....0.....1 */
423         " \u0d02\u0d03\u0d05\u0d06\u0d07\u0d08\u0d09\u0d0a\u0d0b\n\u0d0c \r\u0d0e\u0d0f\u0d10 "
424                 // 2.....3.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E.....F.....
425                 + "\u0d12\u0d13\u0d14\u0d15\u0d16\u0d17\u0d18\u0d19\u0d1a\uffff\u0d1b\u0d1c\u0d1d\u0d1e"
426                 // 012.....3.....4.....5.....6.....7.....89A.....B.....CD.....EF.....0123456789ABC
427                 + " !\u0d1f\u0d20\u0d21\u0d22\u0d23\u0d24)(\u0d25\u0d26,\u0d27.\u0d280123456789:; "
428                 // D.....E.....F0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.....
429                 + "\u0d2a\u0d2b?\u0d2c\u0d2d\u0d2e\u0d2f\u0d30\u0d31\u0d32\u0d33\u0d34\u0d35\u0d36"
430                 // B.....C.....D.....EF.....0.....1.....2.....3.....4.....5.....6.....78.....9.....
431                 + "\u0d37\u0d38\u0d39 \u0d3d\u0d3e\u0d3f\u0d40\u0d41\u0d42\u0d43\u0d44 \u0d46\u0d47"
432                 // A.....BC.....D.....E.....F.....0.....123456789ABCDEF0123456789AB.....C.....D.....
433                 + "\u0d48"
434                 + " \u0d4a\u0d4b\u0d4c\u0d4d\u0d57abcdefghijklmnopqrstuvwxyz\u0d60\u0d61\u0d62"
435                 // E.....F.....
436                 + "\u0d63\u0d79",
437 
438         /* A.3.9 Oriya National Language Locking Shift Table
439         0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.B.....CD.EF.....0.....12 */
440         "\u0b01\u0b02\u0b03\u0b05\u0b06\u0b07\u0b08\u0b09\u0b0a\u0b0b\n\u0b0c \r \u0b0f\u0b10  "
441                 // 3.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E.....F.....01
442                 + "\u0b13\u0b14\u0b15\u0b16\u0b17\u0b18\u0b19\u0b1a\uffff\u0b1b\u0b1c\u0b1d\u0b1e !"
443                 // 2.....3.....4.....5.....6.....7.....89A.....B.....CD.....EF.....0123456789ABCD.....
444                 + "\u0b1f\u0b20\u0b21\u0b22\u0b23\u0b24)(\u0b25\u0b26,\u0b27.\u0b280123456789:;"
445                 + " \u0b2a"
446                 // E.....F0.....1.....2.....3.....4.....56.....7.....89.....A.....B.....C.....D.....
447                 + "\u0b2b?\u0b2c\u0b2d\u0b2e\u0b2f\u0b30 \u0b32\u0b33"
448                 + " \u0b35\u0b36\u0b37\u0b38\u0b39"
449                 // E.....F.....0.....1.....2.....3.....4.....5.....6.....789.....A.....BCD.....E.....
450                 + "\u0b3c\u0b3d\u0b3e\u0b3f\u0b40\u0b41\u0b42\u0b43\u0b44  \u0b47\u0b48 "
451                 + " \u0b4b\u0b4c"
452                 // F.....0.....123456789ABCDEF0123456789AB.....C.....D.....E.....F.....
453                 + "\u0b4d\u0b56abcdefghijklmnopqrstuvwxyz\u0b57\u0b60\u0b61\u0b62\u0b63",
454 
455         /* A.3.10 Punjabi National Language Locking Shift Table
456         0.....1.....2.....3.....4.....5.....6.....7.....8.....9A.BCD.EF.....0.....123.....4.....*/
457         "\u0a01\u0a02\u0a03\u0a05\u0a06\u0a07\u0a08\u0a09\u0a0a \n  \r \u0a0f\u0a10  \u0a13\u0a14"
458                 // 5.....6.....7.....8.....9.....A.....B.....C.....D.....E.....F.....012.....3.....
459                 + "\u0a15\u0a16\u0a17\u0a18\u0a19\u0a1a\uffff\u0a1b\u0a1c\u0a1d\u0a1e !\u0a1f\u0a20"
460                 // 4.....5.....6.....7.....89A.....B.....CD.....EF.....0123456789ABCD.....E.....F0.....
461                 + "\u0a21\u0a22\u0a23\u0a24)(\u0a25\u0a26,\u0a27.\u0a280123456789:;"
462                 + " \u0a2a\u0a2b?\u0a2c"
463                 // 1.....2.....3.....4.....56.....7.....89.....A.....BC.....D.....E.....F0.....1.....
464                 + "\u0a2d\u0a2e\u0a2f\u0a30 \u0a32\u0a33 \u0a35\u0a36 \u0a38\u0a39\u0a3c"
465                 + " \u0a3e\u0a3f"
466                 // 2.....3.....4.....56789.....A.....BCD.....E.....F.....0.....123456789ABCDEF012345678
467                 + "\u0a40\u0a41\u0a42    \u0a47\u0a48 "
468                 + " \u0a4b\u0a4c\u0a4d\u0a51abcdefghijklmnopqrstuvwx"
469                 // 9AB.....C.....D.....E.....F.....
470                 + "yz\u0a70\u0a71\u0a72\u0a73\u0a74",
471 
472         /* A.3.11 Tamil National Language Locking Shift Table
473         01.....2.....3.....4.....5.....6.....7.....8.....9A.BCD.E.....F.....0.....12.....3..... */
474         " \u0b82\u0b83\u0b85\u0b86\u0b87\u0b88\u0b89\u0b8a \n  \r\u0b8e\u0b8f\u0b90 \u0b92\u0b93"
475                 // 4.....5.....6789.....A.....B.....CD.....EF.....012.....3456.....7.....89ABCDEF.....
476                 + "\u0b94\u0b95   \u0b99\u0b9a\uffff \u0b9c \u0b9e !\u0b9f   \u0ba3\u0ba4)(  ,"
477                 + " .\u0ba8"
478                 // 0123456789ABC.....D.....EF012.....3.....4.....5.....6.....7.....8.....9.....A.....
479                 + "0123456789:;\u0ba9\u0baa ? "
480                 + " \u0bae\u0baf\u0bb0\u0bb1\u0bb2\u0bb3\u0bb4\u0bb5\u0bb6"
481                 // B.....C.....D.....EF0.....1.....2.....3.....4.....5678.....9.....A.....BC.....D.....
482                 + "\u0bb7\u0bb8\u0bb9  \u0bbe\u0bbf\u0bc0\u0bc1\u0bc2   \u0bc6\u0bc7\u0bc8"
483                 + " \u0bca\u0bcb"
484                 // E.....F.....0.....123456789ABCDEF0123456789AB.....C.....D.....E.....F.....
485                 + "\u0bcc\u0bcd\u0bd0abcdefghijklmnopqrstuvwxyz\u0bd7\u0bf0\u0bf1\u0bf2\u0bf9",
486 
487         /* A.3.12 Telugu National Language Locking Shift Table
488         0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.B.....CD.E.....F.....0.....*/
489         "\u0c01\u0c02\u0c03\u0c05\u0c06\u0c07\u0c08\u0c09\u0c0a\u0c0b\n\u0c0c \r\u0c0e\u0c0f\u0c10"
490                 // 12.....3.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E.....
491                 + " \u0c12\u0c13\u0c14\u0c15\u0c16\u0c17\u0c18\u0c19\u0c1a\uffff\u0c1b\u0c1c\u0c1d"
492                 // F.....012.....3.....4.....5.....6.....7.....89A.....B.....CD.....EF.....0123456789AB
493                 + "\u0c1e"
494                 + " !\u0c1f\u0c20\u0c21\u0c22\u0c23\u0c24)(\u0c25\u0c26,\u0c27.\u0c280123456789:;"
495                 // CD.....E.....F0.....1.....2.....3.....4.....5.....6.....7.....89.....A.....B.....
496                 + " \u0c2a\u0c2b?\u0c2c\u0c2d\u0c2e\u0c2f\u0c30\u0c31\u0c32\u0c33"
497                 + " \u0c35\u0c36\u0c37"
498                 // C.....D.....EF.....0.....1.....2.....3.....4.....5.....6.....78.....9.....A.....B
499                 + "\u0c38\u0c39 \u0c3d\u0c3e\u0c3f\u0c40\u0c41\u0c42\u0c43\u0c44 \u0c46\u0c47\u0c48"
500                 + " "
501                 // C.....D.....E.....F.....0.....123456789ABCDEF0123456789AB.....C.....D.....E.....
502                 + "\u0c4a\u0c4b\u0c4c\u0c4d\u0c55abcdefghijklmnopqrstuvwxyz\u0c56\u0c60\u0c61\u0c62"
503                 // F.....
504                 + "\u0c63",
505 
506         /* A.3.13 Urdu National Language Locking Shift Table
507         0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.B.....C.....D.E.....F.....*/
508         "\u0627\u0622\u0628\u067b\u0680\u067e\u06a6\u062a\u06c2\u067f\n\u0679\u067d\r\u067a\u067c"
509                 // 0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....
510                 + "\u062b\u062c\u0681\u0684\u0683\u0685\u0686\u0687\u062d\u062e\u062f\uffff\u068c\u0688"
511                 // E.....F.....012.....3.....4.....5.....6.....7.....89A.....B.....CD.....EF.....012345
512                 + "\u0689\u068a"
513                 + " !\u068f\u068d\u0630\u0631\u0691\u0693)(\u0699\u0632,\u0696.\u0698012345"
514                 // 6789ABC.....D.....E.....F0.....1.....2.....3.....4.....5.....6.....7.....8.....
515                 + "6789:;\u069a\u0633\u0634?\u0635\u0636\u0637\u0638\u0639\u0641\u0642\u06a9\u06aa"
516                 // 9.....A.....B.....C.....D.....E.....F.....0.....1.....2.....3.....4.....5.....6.....
517                 + "\u06ab\u06af\u06b3\u06b1\u0644\u0645\u0646\u06ba\u06bb\u06bc\u0648\u06c4\u06d5\u06c1"
518                 // 7.....8.....9.....A.....B.....C.....D.....E.....F.....0.....123456789ABCDEF012345678
519                 + "\u06be\u0621\u06cc\u06d0\u06d2\u064d\u0650\u064f\u0657\u0654abcdefghijklmnopqrstuvwx"
520                 // 9AB.....C.....D.....E.....F.....
521                 + "yz\u0655\u0651\u0653\u0656\u0670"
522     };
523 
524     /** GSM default extension table plus national language single shift character tables. */
525     private static final String[] sLanguageShiftTables =
526             new String[] {
527                 /* 6.2.1.1 GSM 7 bit Default Alphabet Extension Table
528                 0123456789A.....BCDEF0123456789ABCDEF0123456789ABCDEF.0123456789ABCDEF0123456789ABCDEF */
529                 "          \u000c         ^                   {}     \\            [~] |           "
530                         + "    "
531                         // 0123456789ABCDEF012345.....6789ABCDEF0123456789ABCDEF
532                         + "                     \u20ac                          ",
533 
534                 /* A.2.1 Turkish National Language Single Shift Table
535                 0123456789A.....BCDEF0123456789ABCDEF0123456789ABCDEF.0123456789ABCDEF01234567.....8 */
536                 "          \u000c         ^                   {}     \\            [~] |     "
537                         + " \u011e "
538                         // 9.....ABCDEF0123.....456789ABCDEF0123.....45.....67.....89.....ABCDEF0123.....
539                         + "\u0130         \u015e               \u00e7 \u20ac \u011f \u0131        "
540                         + " \u015f"
541                         // 456789ABCDEF
542                         + "            ",
543 
544                 /* A.2.2 Spanish National Language Single Shift Table
545                 0123456789.....A.....BCDEF0123456789ABCDEF0123456789ABCDEF.0123456789ABCDEF01.....23 */
546                 "         \u00e7\u000c         ^                   {}     \\            [~] |\u00c1"
547                         + "  "
548                         // 456789.....ABCDEF.....012345.....6789ABCDEF01.....2345.....6789.....ABCDEF.....012
549                         + "     \u00cd     \u00d3     \u00da           \u00e1   \u20ac   \u00ed    "
550                         + " \u00f3   "
551                         // 345.....6789ABCDEF
552                         + "  \u00fa          ",
553 
554                 /* A.2.3 Portuguese National Language Single Shift Table
555                 012345.....6789.....A.....B.....C.....DE.....F.....012.....3.....45.....6.....7.....8....*/
556                 "     \u00ea   \u00e7\u000c\u00d4\u00f4 \u00c1\u00e1 "
557                         + " \u03a6\u0393^\u03a9\u03a0\u03a8\u03a3"
558                         // 9.....ABCDEF.....0123456789ABCDEF.0123456789ABCDEF01.....23456789.....ABCDE
559                         + "\u0398     \u00ca        {}     \\            [~] |\u00c0       \u00cd  "
560                         + "   "
561                         // F.....012345.....6789AB.....C.....DEF01.....2345.....6789.....ABCDEF.....01234
562                         + "\u00d3     \u00da     \u00c3\u00d5    \u00c2   \u20ac   \u00ed    "
563                         + " \u00f3     "
564                         // 5.....6789AB.....C.....DEF.....
565                         + "\u00fa     \u00e3\u00f5  \u00e2",
566 
567                 /* A.2.4 Bengali National Language Single Shift Table
568                 01.....23.....4.....5.6.....789A.....BCDEF0123.....45.....6789.....A.....BC.....D..... */
569                 "@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+ -/<=>\u00a1^\u00a1_#*\u09e6\u09e7"
570                         + " \u09e8\u09e9"
571                         // E.....F.....0.....1.....2.....3.....4.....5.....6.....7.....89A.....B.....C.....
572                         + "\u09ea\u09eb\u09ec\u09ed\u09ee\u09ef\u09df\u09e0\u09e1\u09e2{}\u09e3\u09f2\u09f3"
573                         // D.....E.....F.0.....1.....2.....3.....4.....56789ABCDEF0123456789ABCDEF
574                         + "\u09f4\u09f5\\\u09f6\u09f7\u09f8\u09f9\u09fa       [~] |ABCDEFGHIJKLMNO"
575                         // 0123456789ABCDEF012345.....6789ABCDEF0123456789ABCDEF
576                         + "PQRSTUVWXYZ          \u20ac                          ",
577 
578                 /* A.2.5 Gujarati National Language Single Shift Table
579                 01.....23.....4.....5.6.....789A.....BCDEF0123.....45.....6789.....A.....BC.....D..... */
580                 "@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+ -/<=>\u00a1^\u00a1_#*\u0964\u0965"
581                         + " \u0ae6\u0ae7"
582                         // E.....F.....0.....1.....2.....3.....4.....5.....6789ABCDEF.0123456789ABCDEF
583                         + "\u0ae8\u0ae9\u0aea\u0aeb\u0aec\u0aed\u0aee\u0aef  {}     \\           "
584                         + " [~] "
585                         // 0123456789ABCDEF0123456789ABCDEF012345.....6789ABCDEF0123456789ABCDEF
586                         + "|ABCDEFGHIJKLMNOPQRSTUVWXYZ          \u20ac                          ",
587 
588                 /* A.2.6 Hindi National Language Single Shift Table
589                 01.....23.....4.....5.6.....789A.....BCDEF0123.....45.....6789.....A.....BC.....D..... */
590                 "@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+ -/<=>\u00a1^\u00a1_#*\u0964\u0965"
591                         + " \u0966\u0967"
592                         // E.....F.....0.....1.....2.....3.....4.....5.....6.....7.....89A.....B.....C.....
593                         + "\u0968\u0969\u096a\u096b\u096c\u096d\u096e\u096f\u0951\u0952{}\u0953\u0954\u0958"
594                         // D.....E.....F.0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.....
595                         + "\u0959\u095a\\\u095b\u095c\u095d\u095e\u095f\u0960\u0961\u0962\u0963\u0970\u0971"
596                         // BCDEF0123456789ABCDEF0123456789ABCDEF012345.....6789ABCDEF0123456789ABCDEF
597                         + " [~] |ABCDEFGHIJKLMNOPQRSTUVWXYZ          \u20ac                        "
598                         + "  ",
599 
600                 /* A.2.7 Kannada National Language Single Shift Table
601                 01.....23.....4.....5.6.....789A.....BCDEF0123.....45.....6789.....A.....BC.....D..... */
602                 "@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+ -/<=>\u00a1^\u00a1_#*\u0964\u0965"
603                         + " \u0ce6\u0ce7"
604                         // E.....F.....0.....1.....2.....3.....4.....5.....6.....7.....89A.....BCDEF.01234567
605                         + "\u0ce8\u0ce9\u0cea\u0ceb\u0cec\u0ced\u0cee\u0cef\u0cde\u0cf1{}\u0cf2   "
606                         + " \\        "
607                         // 89ABCDEF0123456789ABCDEF0123456789ABCDEF012345.....6789ABCDEF0123456789ABCDEF
608                         + "    [~] |ABCDEFGHIJKLMNOPQRSTUVWXYZ          \u20ac                     "
609                         + "     ",
610 
611                 /* A.2.8 Malayalam National Language Single Shift Table
612                 01.....23.....4.....5.6.....789A.....BCDEF0123.....45.....6789.....A.....BC.....D..... */
613                 "@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+ -/<=>\u00a1^\u00a1_#*\u0964\u0965"
614                         + " \u0d66\u0d67"
615                         // E.....F.....0.....1.....2.....3.....4.....5.....6.....7.....89A.....B.....C.....
616                         + "\u0d68\u0d69\u0d6a\u0d6b\u0d6c\u0d6d\u0d6e\u0d6f\u0d70\u0d71{}\u0d72\u0d73\u0d74"
617                         // D.....E.....F.0.....1.....2.....3.....4.....56789ABCDEF0123456789ABCDEF0123456789A
618                         + "\u0d75\u0d7a\\\u0d7b\u0d7c\u0d7d\u0d7e\u0d7f       [~]"
619                         + " |ABCDEFGHIJKLMNOPQRSTUVWXYZ"
620                         // BCDEF012345.....6789ABCDEF0123456789ABCDEF
621                         + "          \u20ac                          ",
622 
623                 /* A.2.9 Oriya National Language Single Shift Table
624                 01.....23.....4.....5.6.....789A.....BCDEF0123.....45.....6789.....A.....BC.....D..... */
625                 "@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+ -/<=>\u00a1^\u00a1_#*\u0964\u0965"
626                         + " \u0b66\u0b67"
627                         // E.....F.....0.....1.....2.....3.....4.....5.....6.....7.....89A.....B.....C.....DE
628                         + "\u0b68\u0b69\u0b6a\u0b6b\u0b6c\u0b6d\u0b6e\u0b6f\u0b5c\u0b5d{}\u0b5f\u0b70\u0b71"
629                         + "  "
630                         // F.0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF012345.....6789ABCDEF0123456789A
631                         + "\\            [~] |ABCDEFGHIJKLMNOPQRSTUVWXYZ          \u20ac           "
632                         + "          "
633                         // BCDEF
634                         + "     ",
635 
636                 /* A.2.10 Punjabi National Language Single Shift Table
637                 01.....23.....4.....5.6.....789A.....BCDEF0123.....45.....6789.....A.....BC.....D..... */
638                 "@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+ -/<=>\u00a1^\u00a1_#*\u0964\u0965"
639                         + " \u0a66\u0a67"
640                         // E.....F.....0.....1.....2.....3.....4.....5.....6.....7.....89A.....B.....C.....
641                         + "\u0a68\u0a69\u0a6a\u0a6b\u0a6c\u0a6d\u0a6e\u0a6f\u0a59\u0a5a{}\u0a5b\u0a5c\u0a5e"
642                         // D.....EF.0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF012345.....6789ABCDEF01
643                         + "\u0a75 \\            [~] |ABCDEFGHIJKLMNOPQRSTUVWXYZ          \u20ac    "
644                         + "        "
645                         // 23456789ABCDEF
646                         + "              ",
647 
648                 /* A.2.11 Tamil National Language Single Shift Table
649                   NOTE: TS 23.038 V9.1.1 shows code 0x24 as \u0bef, corrected to \u0bee (typo)
650                 01.....23.....4.....5.6.....789A.....BCDEF0123.....45.....6789.....A.....BC.....D..... */
651                 "@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+ -/<=>\u00a1^\u00a1_#*\u0964\u0965"
652                         + " \u0be6\u0be7"
653                         // E.....F.....0.....1.....2.....3.....4.....5.....6.....7.....89A.....B.....C.....
654                         + "\u0be8\u0be9\u0bea\u0beb\u0bec\u0bed\u0bee\u0bef\u0bf3\u0bf4{}\u0bf5\u0bf6\u0bf7"
655                         // D.....E.....F.0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF012345.....6789ABC
656                         + "\u0bf8\u0bfa\\            [~] |ABCDEFGHIJKLMNOPQRSTUVWXYZ         "
657                         + " \u20ac       "
658                         // DEF0123456789ABCDEF
659                         + "                   ",
660 
661                 /* A.2.12 Telugu National Language Single Shift Table
662                   NOTE: TS 23.038 V9.1.1 shows code 0x22-0x23 as \u06cc\u06cd, corrected to \u0c6c\u0c6d
663                 01.....23.....4.....5.6.....789A.....BCDEF0123.....45.....6789ABC.....D.....E.....F..... */
664                 "@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+ -/<=>\u00a1^\u00a1_#*  "
665                         + " \u0c66\u0c67\u0c68\u0c69"
666                         // 0.....1.....2.....3.....4.....5.....6.....7.....89A.....B.....C.....D.....E.....F.
667                         + "\u0c6a\u0c6b\u0c6c\u0c6d\u0c6e\u0c6f\u0c58\u0c59{}\u0c78\u0c79\u0c7a\u0c7b\u0c7c\\"
668                         // 0.....1.....2.....3456789ABCDEF0123456789ABCDEF0123456789ABCDEF012345.....6789ABCD
669                         + "\u0c7d\u0c7e\u0c7f         [~] |ABCDEFGHIJKLMNOPQRSTUVWXYZ         "
670                         + " \u20ac        "
671                         // EF0123456789ABCDEF
672                         + "                  ",
673 
674                 /* A.2.13 Urdu National Language Single Shift Table
675                 01.....23.....4.....5.6.....789A.....BCDEF0123.....45.....6789.....A.....BC.....D..... */
676                 "@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+ -/<=>\u00a1^\u00a1_#*\u0600\u0601"
677                         + " \u06f0\u06f1"
678                         // E.....F.....0.....1.....2.....3.....4.....5.....6.....7.....89A.....B.....C.....
679                         + "\u06f2\u06f3\u06f4\u06f5\u06f6\u06f7\u06f8\u06f9\u060c\u060d{}\u060e\u060f\u0610"
680                         // D.....E.....F.0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.....
681                         + "\u0611\u0612\\\u0613\u0614\u061b\u061f\u0640\u0652\u0658\u066b\u066c\u0672\u0673"
682                         // B.....CDEF.....0123456789ABCDEF0123456789ABCDEF012345.....6789ABCDEF0123456789ABCDEF
683                         + "\u06cd[~]\u06d4|ABCDEFGHIJKLMNOPQRSTUVWXYZ          \u20ac              "
684                         + "            "
685             };
686 
687     static {
688         int numTables = sLanguageTables.length;
689         int numShiftTables = sLanguageShiftTables.length;
690         if (numTables != numShiftTables) {
Log.e( TAG, "Error: language tables array length " + numTables + " != shift tables array length " + numShiftTables)691             Log.e(
692                     TAG,
693                     "Error: language tables array length "
694                             + numTables
695                             + " != shift tables array length "
696                             + numShiftTables);
697         }
698 
699         sCharsToGsmTables = new SparseIntArray[numTables];
700         for (int i = 0; i < numTables; i++) {
701             String table = sLanguageTables[i];
702 
703             int tableLen = table.length();
704             if (tableLen != 0 && tableLen != 128) {
Log.e( TAG, "Error: language tables index " + i + " length " + tableLen + " (expected 128 or 0)")705                 Log.e(
706                         TAG,
707                         "Error: language tables index "
708                                 + i
709                                 + " length "
710                                 + tableLen
711                                 + " (expected 128 or 0)");
712             }
713 
714             SparseIntArray charToGsmTable = new SparseIntArray(tableLen);
715             sCharsToGsmTables[i] = charToGsmTable;
716             for (int j = 0; j < tableLen; j++) {
717                 char c = table.charAt(j);
charToGsmTable.put(c, j)718                 charToGsmTable.put(c, j);
719             }
720         }
721 
722         sCharsToShiftTables = new SparseIntArray[numShiftTables];
723         for (int i = 0; i < numShiftTables; i++) {
724             String shiftTable = sLanguageShiftTables[i];
725 
726             int shiftTableLen = shiftTable.length();
727             if (shiftTableLen != 0 && shiftTableLen != 128) {
Log.e( TAG, "Error: language shift tables index " + i + " length " + shiftTableLen + " (expected 128 or 0)")728                 Log.e(
729                         TAG,
730                         "Error: language shift tables index "
731                                 + i
732                                 + " length "
733                                 + shiftTableLen
734                                 + " (expected 128 or 0)");
735             }
736 
737             SparseIntArray charToShiftTable = new SparseIntArray(shiftTableLen);
738             sCharsToShiftTables[i] = charToShiftTable;
739             for (int j = 0; j < shiftTableLen; j++) {
740                 char c = shiftTable.charAt(j);
741                 if (c != ' ') {
charToShiftTable.put(c, j)742                     charToShiftTable.put(c, j);
743                 }
744             }
745         }
746     }
747 }
748