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 com.android.internal.telephony; 18 19 import android.annotation.UnsupportedAppUsage; 20 import android.content.res.Resources; 21 import android.os.Build; 22 import android.telephony.Rlog; 23 import android.text.TextUtils; 24 import android.util.SparseIntArray; 25 26 import com.android.internal.R; 27 28 import java.nio.ByteBuffer; 29 import java.nio.charset.Charset; 30 import java.util.ArrayList; 31 import java.util.List; 32 33 /** 34 * This class implements the character set mapping between 35 * the GSM SMS 7-bit alphabet specified in TS 23.038 6.2.1 36 * and UTF-16 37 * 38 * {@hide} 39 */ 40 public class GsmAlphabet { 41 private static final String TAG = "GSM"; 42 GsmAlphabet()43 private GsmAlphabet() { } 44 45 /** 46 * This escapes extended characters, and when present indicates that the 47 * following character should be looked up in the "extended" table. 48 * 49 * gsmToChar(GSM_EXTENDED_ESCAPE) returns 0xffff 50 */ 51 public static final byte GSM_EXTENDED_ESCAPE = 0x1B; 52 53 /** 54 * User data header requires one octet for length. Count as one septet, because 55 * all combinations of header elements below will have at least one free bit 56 * when padding to the nearest septet boundary. 57 */ 58 public static final int UDH_SEPTET_COST_LENGTH = 1; 59 60 /** 61 * Using a non-default language locking shift table OR single shift table 62 * requires a user data header of 3 octets, or 4 septets, plus UDH length. 63 */ 64 public static final int UDH_SEPTET_COST_ONE_SHIFT_TABLE = 4; 65 66 /** 67 * Using a non-default language locking shift table AND single shift table 68 * requires a user data header of 6 octets, or 7 septets, plus UDH length. 69 */ 70 public static final int UDH_SEPTET_COST_TWO_SHIFT_TABLES = 7; 71 72 /** 73 * Multi-part messages require a user data header of 5 octets, or 6 septets, 74 * plus UDH length. 75 */ 76 public static final int UDH_SEPTET_COST_CONCATENATED_MESSAGE = 6; 77 78 /** 79 * For a specific text string, this object describes protocol 80 * properties of encoding it for transmission as message user 81 * data. 82 */ 83 public static class TextEncodingDetails { 84 /** 85 *The number of SMS's required to encode the text. 86 */ 87 @UnsupportedAppUsage 88 public int msgCount; 89 90 /** 91 * The number of code units consumed so far, where code units 92 * are basically characters in the encoding -- for example, 93 * septets for the standard ASCII and GSM encodings, and 16 94 * bits for Unicode. 95 */ 96 @UnsupportedAppUsage 97 public int codeUnitCount; 98 99 /** 100 * How many code units are still available without spilling 101 * into an additional message. 102 */ 103 @UnsupportedAppUsage 104 public int codeUnitsRemaining; 105 106 /** 107 * The encoding code unit size (specified using 108 * android.telephony.SmsMessage ENCODING_*). 109 */ 110 @UnsupportedAppUsage 111 public int codeUnitSize; 112 113 /** 114 * The GSM national language table to use, or 0 for the default 7-bit alphabet. 115 */ 116 @UnsupportedAppUsage 117 public int languageTable; 118 119 /** 120 * The GSM national language shift table to use, or 0 for the default 7-bit extension table. 121 */ 122 @UnsupportedAppUsage 123 public int languageShiftTable; 124 125 @Override toString()126 public String toString() { 127 return "TextEncodingDetails " + 128 "{ msgCount=" + msgCount + 129 ", codeUnitCount=" + codeUnitCount + 130 ", codeUnitsRemaining=" + codeUnitsRemaining + 131 ", codeUnitSize=" + codeUnitSize + 132 ", languageTable=" + languageTable + 133 ", languageShiftTable=" + languageShiftTable + 134 " }"; 135 } 136 } 137 138 /** 139 * Converts a char to a GSM 7 bit table index. 140 * Returns ' ' in GSM alphabet if there's no possible match. Returns 141 * GSM_EXTENDED_ESCAPE if this character is in the extended table. 142 * In this case, you must call charToGsmExtended() for the value 143 * that should follow GSM_EXTENDED_ESCAPE in the GSM alphabet string. 144 * @param c the character to convert 145 * @return the GSM 7 bit table index for the specified character 146 */ 147 @UnsupportedAppUsage 148 public static int charToGsm(char c)149 charToGsm(char c) { 150 try { 151 return charToGsm(c, false); 152 } catch (EncodeException ex) { 153 // this should never happen 154 return sCharsToGsmTables[0].get(' ', ' '); 155 } 156 } 157 158 /** 159 * Converts a char to a GSM 7 bit table index. 160 * Returns GSM_EXTENDED_ESCAPE if this character is in the extended table. 161 * In this case, you must call charToGsmExtended() for the value that 162 * should follow GSM_EXTENDED_ESCAPE in the GSM alphabet string. 163 * 164 * @param c the character to convert 165 * @param throwException If true, throws EncodeException on invalid char. 166 * If false, returns GSM alphabet ' ' char. 167 * @throws EncodeException encode error when throwException is true 168 * @return the GSM 7 bit table index for the specified character 169 */ 170 @UnsupportedAppUsage 171 public static int charToGsm(char c, boolean throwException)172 charToGsm(char c, boolean throwException) throws EncodeException { 173 int ret; 174 175 ret = sCharsToGsmTables[0].get(c, -1); 176 177 if (ret == -1) { 178 ret = sCharsToShiftTables[0].get(c, -1); 179 180 if (ret == -1) { 181 if (throwException) { 182 throw new EncodeException(c); 183 } else { 184 return sCharsToGsmTables[0].get(' ', ' '); 185 } 186 } else { 187 return GSM_EXTENDED_ESCAPE; 188 } 189 } 190 191 return ret; 192 } 193 194 /** 195 * Converts a char to an extended GSM 7 bit table index. 196 * Extended chars should be escaped with GSM_EXTENDED_ESCAPE. 197 * Returns ' ' in GSM alphabet if there's no possible match. 198 * @param c the character to convert 199 * @return the GSM 7 bit extended table index for the specified character 200 */ 201 public static int charToGsmExtended(char c)202 charToGsmExtended(char c) { 203 int ret; 204 205 ret = sCharsToShiftTables[0].get(c, -1); 206 207 if (ret == -1) { 208 return sCharsToGsmTables[0].get(' ', ' '); 209 } 210 211 return ret; 212 } 213 214 /** 215 * Converts a character in the GSM alphabet into a char. 216 * 217 * If GSM_EXTENDED_ESCAPE is passed, 0xffff is returned. In this case, 218 * the following character in the stream should be decoded with 219 * gsmExtendedToChar(). 220 * 221 * If an unmappable value is passed (one greater than 127), ' ' is returned. 222 * 223 * @param gsmChar the GSM 7 bit table index to convert 224 * @return the decoded character 225 */ 226 @UnsupportedAppUsage 227 public static char gsmToChar(int gsmChar)228 gsmToChar(int gsmChar) { 229 if (gsmChar >= 0 && gsmChar < 128) { 230 return sLanguageTables[0].charAt(gsmChar); 231 } else { 232 return ' '; 233 } 234 } 235 236 /** 237 * Converts a character in the extended GSM alphabet into a char 238 * 239 * if GSM_EXTENDED_ESCAPE is passed, ' ' is returned since no second 240 * extension page has yet been defined (see Note 1 in table 6.2.1.1 of 241 * TS 23.038 v7.00) 242 * 243 * If an unmappable value is passed, the character from the GSM 7 bit 244 * default table will be used (table 6.2.1.1 of TS 23.038). 245 * 246 * @param gsmChar the GSM 7 bit extended table index to convert 247 * @return the decoded character 248 */ 249 public static char gsmExtendedToChar(int gsmChar)250 gsmExtendedToChar(int gsmChar) { 251 if (gsmChar == GSM_EXTENDED_ESCAPE) { 252 return ' '; 253 } else if (gsmChar >= 0 && gsmChar < 128) { 254 char c = sLanguageShiftTables[0].charAt(gsmChar); 255 if (c == ' ') { 256 return sLanguageTables[0].charAt(gsmChar); 257 } else { 258 return c; 259 } 260 } else { 261 return ' '; // out of range 262 } 263 } 264 265 /** 266 * Converts a String into a byte array containing the 7-bit packed 267 * GSM Alphabet representation of the string. If a header is provided, 268 * this is included in the returned byte array and padded to a septet 269 * boundary. This method is used by OEM code. 270 * 271 * @param data The text string to encode. 272 * @param header Optional header (including length byte) that precedes 273 * the encoded data, padded to septet boundary. 274 * @return Byte array containing header and encoded data. 275 * @throws EncodeException if String is too large to encode 276 * @see #stringToGsm7BitPackedWithHeader(String, byte[], int, int) 277 */ stringToGsm7BitPackedWithHeader(String data, byte[] header)278 public static byte[] stringToGsm7BitPackedWithHeader(String data, byte[] header) 279 throws EncodeException { 280 return stringToGsm7BitPackedWithHeader(data, header, 0, 0); 281 } 282 283 /** 284 * Converts a String into a byte array containing the 7-bit packed 285 * GSM Alphabet representation of the string. If a header is provided, 286 * this is included in the returned byte array and padded to a septet 287 * boundary. 288 * 289 * Unencodable chars are encoded as spaces 290 * 291 * Byte 0 in the returned byte array is the count of septets used, 292 * including the header and header padding. The returned byte array is 293 * the minimum size required to store the packed septets. The returned 294 * array cannot contain more than 255 septets. 295 * 296 * @param data The text string to encode. 297 * @param header Optional header (including length byte) that precedes 298 * the encoded data, padded to septet boundary. 299 * @param languageTable the 7 bit language table, or 0 for the default GSM alphabet 300 * @param languageShiftTable the 7 bit single shift language table, or 0 for the default 301 * GSM extension table 302 * @return Byte array containing header and encoded data. 303 * @throws EncodeException if String is too large to encode 304 */ 305 @UnsupportedAppUsage stringToGsm7BitPackedWithHeader(String data, byte[] header, int languageTable, int languageShiftTable)306 public static byte[] stringToGsm7BitPackedWithHeader(String data, byte[] header, 307 int languageTable, int languageShiftTable) 308 throws EncodeException { 309 if (header == null || header.length == 0) { 310 return stringToGsm7BitPacked(data, languageTable, languageShiftTable); 311 } 312 313 int headerBits = (header.length + 1) * 8; 314 int headerSeptets = (headerBits + 6) / 7; 315 316 byte[] ret = stringToGsm7BitPacked(data, headerSeptets, true, languageTable, 317 languageShiftTable); 318 319 // Paste in the header 320 ret[1] = (byte)header.length; 321 System.arraycopy(header, 0, ret, 2, header.length); 322 return ret; 323 } 324 325 /** 326 * Converts a String into a byte array containing 327 * the 7-bit packed GSM Alphabet representation of the string. 328 * 329 * Unencodable chars are encoded as spaces 330 * 331 * Byte 0 in the returned byte array is the count of septets used 332 * The returned byte array is the minimum size required to store 333 * the packed septets. The returned array cannot contain more than 255 334 * septets. 335 * 336 * @param data the data string to encode 337 * @return the encoded string 338 * @throws EncodeException if String is too large to encode 339 */ 340 @UnsupportedAppUsage stringToGsm7BitPacked(String data)341 public static byte[] stringToGsm7BitPacked(String data) 342 throws EncodeException { 343 return stringToGsm7BitPacked(data, 0, true, 0, 0); 344 } 345 346 /** 347 * Converts a String into a byte array containing 348 * the 7-bit packed GSM Alphabet representation of the string. 349 * 350 * Unencodable chars are encoded as spaces 351 * 352 * Byte 0 in the returned byte array is the count of septets used 353 * The returned byte array is the minimum size required to store 354 * the packed septets. The returned array cannot contain more than 255 355 * septets. 356 * 357 * @param data the data string to encode 358 * @param languageTable the 7 bit language table, or 0 for the default GSM alphabet 359 * @param languageShiftTable the 7 bit single shift language table, or 0 for the default 360 * GSM extension table 361 * @return the encoded string 362 * @throws EncodeException if String is too large to encode 363 */ stringToGsm7BitPacked(String data, int languageTable, int languageShiftTable)364 public static byte[] stringToGsm7BitPacked(String data, int languageTable, 365 int languageShiftTable) 366 throws EncodeException { 367 return stringToGsm7BitPacked(data, 0, true, languageTable, languageShiftTable); 368 } 369 370 /** 371 * Converts a String into a byte array containing 372 * the 7-bit packed GSM Alphabet representation of the string. 373 * 374 * Byte 0 in the returned byte array is the count of septets used 375 * The returned byte array is the minimum size required to store 376 * the packed septets. The returned array cannot contain more than 255 377 * septets. 378 * 379 * @param data the text to convert to septets 380 * @param startingSeptetOffset the number of padding septets to put before 381 * the character data at the beginning of the array 382 * @param throwException If true, throws EncodeException on invalid char. 383 * If false, replaces unencodable char with GSM alphabet space char. 384 * @param languageTable the 7 bit language table, or 0 for the default GSM alphabet 385 * @param languageShiftTable the 7 bit single shift language table, or 0 for the default 386 * GSM extension table 387 * @return the encoded message 388 * 389 * @throws EncodeException if String is too large to encode or any characters are unencodable 390 */ 391 @UnsupportedAppUsage stringToGsm7BitPacked(String data, int startingSeptetOffset, boolean throwException, int languageTable, int languageShiftTable)392 public static byte[] stringToGsm7BitPacked(String data, int startingSeptetOffset, 393 boolean throwException, int languageTable, int languageShiftTable) 394 throws EncodeException { 395 int dataLen = data.length(); 396 int septetCount = countGsmSeptetsUsingTables(data, !throwException, 397 languageTable, languageShiftTable); 398 if (septetCount == -1) { 399 throw new EncodeException("countGsmSeptetsUsingTables(): unencodable char"); 400 } 401 septetCount += startingSeptetOffset; 402 if (septetCount > 255) { 403 throw new EncodeException( 404 "Payload cannot exceed 255 septets", EncodeException.ERROR_EXCEED_SIZE); 405 } 406 int byteCount = ((septetCount * 7) + 7) / 8; 407 byte[] ret = new byte[byteCount + 1]; // Include space for one byte length prefix. 408 SparseIntArray charToLanguageTable = sCharsToGsmTables[languageTable]; 409 SparseIntArray charToShiftTable = sCharsToShiftTables[languageShiftTable]; 410 for (int i = 0, septets = startingSeptetOffset, bitOffset = startingSeptetOffset * 7; 411 i < dataLen && septets < septetCount; 412 i++, bitOffset += 7) { 413 char c = data.charAt(i); 414 int v = charToLanguageTable.get(c, -1); 415 if (v == -1) { 416 v = charToShiftTable.get(c, -1); // Lookup the extended char. 417 if (v == -1) { 418 if (throwException) { 419 throw new EncodeException("stringToGsm7BitPacked(): unencodable char"); 420 } else { 421 v = charToLanguageTable.get(' ', ' '); // should return ASCII space 422 } 423 } else { 424 packSmsChar(ret, bitOffset, GSM_EXTENDED_ESCAPE); 425 bitOffset += 7; 426 septets++; 427 } 428 } 429 packSmsChar(ret, bitOffset, v); 430 septets++; 431 } 432 ret[0] = (byte) (septetCount); // Validated by check above. 433 return ret; 434 } 435 436 /** 437 * Pack a 7-bit char into its appropriate place in a byte array 438 * 439 * @param packedChars the destination byte array 440 * @param bitOffset the bit offset that the septet should be packed at 441 * (septet index * 7) 442 * @param value the 7-bit character to store 443 */ 444 @UnsupportedAppUsage 445 private static void packSmsChar(byte[] packedChars, int bitOffset, int value)446 packSmsChar(byte[] packedChars, int bitOffset, int value) { 447 int byteOffset = bitOffset / 8; 448 int shift = bitOffset % 8; 449 450 packedChars[++byteOffset] |= value << shift; 451 452 if (shift > 1) { 453 packedChars[++byteOffset] = (byte)(value >> (8 - shift)); 454 } 455 } 456 457 /** 458 * Convert a GSM alphabet 7 bit packed string (SMS string) into a 459 * {@link java.lang.String}. 460 * 461 * See TS 23.038 6.1.2.1 for SMS Character Packing 462 * 463 * @param pdu the raw data from the pdu 464 * @param offset the byte offset of 465 * @param lengthSeptets string length in septets, not bytes 466 * @return String representation or null on decoding exception 467 */ 468 @UnsupportedAppUsage gsm7BitPackedToString(byte[] pdu, int offset, int lengthSeptets)469 public static String gsm7BitPackedToString(byte[] pdu, int offset, 470 int lengthSeptets) { 471 return gsm7BitPackedToString(pdu, offset, lengthSeptets, 0, 0, 0); 472 } 473 474 /** 475 * Convert a GSM alphabet 7 bit packed string (SMS string) into a 476 * {@link java.lang.String}. 477 * 478 * See TS 23.038 6.1.2.1 for SMS Character Packing 479 * 480 * @param pdu the raw data from the pdu 481 * @param offset the byte offset of 482 * @param lengthSeptets string length in septets, not bytes 483 * @param numPaddingBits the number of padding bits before the start of the 484 * string in the first byte 485 * @param languageTable the 7 bit language table, or 0 for the default GSM alphabet 486 * @param shiftTable the 7 bit single shift language table, or 0 for the default 487 * GSM extension table 488 * @return String representation or null on decoding exception 489 */ 490 @UnsupportedAppUsage gsm7BitPackedToString(byte[] pdu, int offset, int lengthSeptets, int numPaddingBits, int languageTable, int shiftTable)491 public static String gsm7BitPackedToString(byte[] pdu, int offset, 492 int lengthSeptets, int numPaddingBits, int languageTable, int shiftTable) { 493 StringBuilder ret = new StringBuilder(lengthSeptets); 494 495 if (languageTable < 0 || languageTable > sLanguageTables.length) { 496 Rlog.w(TAG, "unknown language table " + languageTable + ", using default"); 497 languageTable = 0; 498 } 499 if (shiftTable < 0 || shiftTable > sLanguageShiftTables.length) { 500 Rlog.w(TAG, "unknown single shift table " + shiftTable + ", using default"); 501 shiftTable = 0; 502 } 503 504 try { 505 boolean prevCharWasEscape = false; 506 String languageTableToChar = sLanguageTables[languageTable]; 507 String shiftTableToChar = sLanguageShiftTables[shiftTable]; 508 509 if (languageTableToChar.isEmpty()) { 510 Rlog.w(TAG, "no language table for code " + languageTable + ", using default"); 511 languageTableToChar = sLanguageTables[0]; 512 } 513 if (shiftTableToChar.isEmpty()) { 514 Rlog.w(TAG, "no single shift table for code " + shiftTable + ", using default"); 515 shiftTableToChar = sLanguageShiftTables[0]; 516 } 517 518 for (int i = 0 ; i < lengthSeptets ; i++) { 519 int bitOffset = (7 * i) + numPaddingBits; 520 521 int byteOffset = bitOffset / 8; 522 int shift = bitOffset % 8; 523 int gsmVal; 524 525 gsmVal = (0x7f & (pdu[offset + byteOffset] >> shift)); 526 527 // if it crosses a byte boundary 528 if (shift > 1) { 529 // set msb bits to 0 530 gsmVal &= 0x7f >> (shift - 1); 531 532 gsmVal |= 0x7f & (pdu[offset + byteOffset + 1] << (8 - shift)); 533 } 534 535 if (prevCharWasEscape) { 536 if (gsmVal == GSM_EXTENDED_ESCAPE) { 537 ret.append(' '); // display ' ' for reserved double escape sequence 538 } else { 539 char c = shiftTableToChar.charAt(gsmVal); 540 if (c == ' ') { 541 ret.append(languageTableToChar.charAt(gsmVal)); 542 } else { 543 ret.append(c); 544 } 545 } 546 prevCharWasEscape = false; 547 } else if (gsmVal == GSM_EXTENDED_ESCAPE) { 548 prevCharWasEscape = true; 549 } else { 550 ret.append(languageTableToChar.charAt(gsmVal)); 551 } 552 } 553 } catch (RuntimeException ex) { 554 Rlog.e(TAG, "Error GSM 7 bit packed: ", ex); 555 return null; 556 } 557 558 return ret.toString(); 559 } 560 561 562 /** 563 * Convert a GSM alphabet string that's stored in 8-bit unpacked 564 * format (as it often appears in SIM records) into a String 565 * 566 * Field may be padded with trailing 0xff's. The decode stops 567 * at the first 0xff encountered. 568 * 569 * @param data the byte array to decode 570 * @param offset array offset for the first character to decode 571 * @param length the number of bytes to decode 572 * @return the decoded string 573 */ 574 @UnsupportedAppUsage 575 public static String gsm8BitUnpackedToString(byte[] data, int offset, int length)576 gsm8BitUnpackedToString(byte[] data, int offset, int length) { 577 return gsm8BitUnpackedToString(data, offset, length, ""); 578 } 579 580 /** 581 * Convert a GSM alphabet string that's stored in 8-bit unpacked 582 * format (as it often appears in SIM records) into a String 583 * 584 * Field may be padded with trailing 0xff's. The decode stops 585 * at the first 0xff encountered. 586 * 587 * Additionally, in some country(ex. Korea), there are non-ASCII or MBCS characters. 588 * If a character set is given, characters in data are treat as MBCS. 589 */ 590 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) 591 public static String gsm8BitUnpackedToString(byte[] data, int offset, int length, String characterset)592 gsm8BitUnpackedToString(byte[] data, int offset, int length, String characterset) { 593 boolean isMbcs = false; 594 Charset charset = null; 595 ByteBuffer mbcsBuffer = null; 596 597 if (!TextUtils.isEmpty(characterset) 598 && !characterset.equalsIgnoreCase("us-ascii") 599 && Charset.isSupported(characterset)) { 600 isMbcs = true; 601 charset = Charset.forName(characterset); 602 mbcsBuffer = ByteBuffer.allocate(2); 603 } 604 605 // Always use GSM 7 bit default alphabet table for this method 606 String languageTableToChar = sLanguageTables[0]; 607 String shiftTableToChar = sLanguageShiftTables[0]; 608 609 StringBuilder ret = new StringBuilder(length); 610 boolean prevWasEscape = false; 611 for (int i = offset ; i < offset + length ; i++) { 612 // Never underestimate the pain that can be caused 613 // by signed bytes 614 int c = data[i] & 0xff; 615 616 if (c == 0xff) { 617 break; 618 } else if (c == GSM_EXTENDED_ESCAPE) { 619 if (prevWasEscape) { 620 // Two escape chars in a row 621 // We treat this as a space 622 // See Note 1 in table 6.2.1.1 of TS 23.038 v7.00 623 ret.append(' '); 624 prevWasEscape = false; 625 } else { 626 prevWasEscape = true; 627 } 628 } else { 629 if (prevWasEscape) { 630 char shiftChar = 631 c < shiftTableToChar.length() ? shiftTableToChar.charAt(c) : ' '; 632 if (shiftChar == ' ') { 633 // display character from main table if not present in shift table 634 if (c < languageTableToChar.length()) { 635 ret.append(languageTableToChar.charAt(c)); 636 } else { 637 ret.append(' '); 638 } 639 } else { 640 ret.append(shiftChar); 641 } 642 } else { 643 if (!isMbcs || c < 0x80 || i + 1 >= offset + length) { 644 if (c < languageTableToChar.length()) { 645 ret.append(languageTableToChar.charAt(c)); 646 } else { 647 ret.append(' '); 648 } 649 } else { 650 // isMbcs must be true. So both mbcsBuffer and charset are initialized. 651 mbcsBuffer.clear(); 652 mbcsBuffer.put(data, i++, 2); 653 mbcsBuffer.flip(); 654 ret.append(charset.decode(mbcsBuffer).toString()); 655 } 656 } 657 prevWasEscape = false; 658 } 659 } 660 661 return ret.toString(); 662 } 663 664 /** 665 * Convert a string into an 8-bit unpacked GSM alphabet byte array. 666 * Always uses GSM default 7-bit alphabet and extension table. 667 * @param s the string to encode 668 * @return the 8-bit GSM encoded byte array for the string 669 */ 670 @UnsupportedAppUsage 671 public static byte[] 672 stringToGsm8BitPacked(String s) { 673 byte[] ret; 674 675 int septets = countGsmSeptetsUsingTables(s, true, 0, 0); 676 677 // Enough for all the septets and the length byte prefix 678 ret = new byte[septets]; 679 680 stringToGsm8BitUnpackedField(s, ret, 0, ret.length); 681 682 return ret; 683 } 684 685 686 /** 687 * Write a String into a GSM 8-bit unpacked field of 688 * Field is padded with 0xff's, string is truncated if necessary 689 * 690 * @param s the string to encode 691 * @param dest the destination byte array 692 * @param offset the starting offset for the encoded string 693 * @param length the maximum number of bytes to write 694 */ 695 public static void 696 stringToGsm8BitUnpackedField(String s, byte dest[], int offset, int length) { 697 int outByteIndex = offset; 698 SparseIntArray charToLanguageTable = sCharsToGsmTables[0]; 699 SparseIntArray charToShiftTable = sCharsToShiftTables[0]; 700 701 // Septets are stored in byte-aligned octets 702 for (int i = 0, sz = s.length() 703 ; i < sz && (outByteIndex - offset) < length 704 ; i++ 705 ) { 706 char c = s.charAt(i); 707 708 int v = charToLanguageTable.get(c, -1); 709 710 if (v == -1) { 711 v = charToShiftTable.get(c, -1); 712 if (v == -1) { 713 v = charToLanguageTable.get(' ', ' '); // fall back to ASCII space 714 } else { 715 // make sure we can fit an escaped char 716 if (! (outByteIndex + 1 - offset < length)) { 717 break; 718 } 719 720 dest[outByteIndex++] = GSM_EXTENDED_ESCAPE; 721 } 722 } 723 724 dest[outByteIndex++] = (byte)v; 725 } 726 727 // pad with 0xff's 728 while((outByteIndex - offset) < length) { 729 dest[outByteIndex++] = (byte)0xff; 730 } 731 } 732 733 /** 734 * Returns the count of 7-bit GSM alphabet characters 735 * needed to represent this character. Counts unencodable char as 1 septet. 736 * @param c the character to examine 737 * @return the number of septets for this character 738 */ 739 public static int 740 countGsmSeptets(char c) { 741 try { 742 return countGsmSeptets(c, false); 743 } catch (EncodeException ex) { 744 // This should never happen. 745 return 0; 746 } 747 } 748 749 /** 750 * Returns the count of 7-bit GSM alphabet characters 751 * needed to represent this character using the default 7 bit GSM alphabet. 752 * @param c the character to examine 753 * @param throwsException If true, throws EncodeException if unencodable 754 * char. Otherwise, counts invalid char as 1 septet. 755 * @return the number of septets for this character 756 * @throws EncodeException the character can't be encoded and throwsException is true 757 */ 758 @UnsupportedAppUsage 759 public static int 760 countGsmSeptets(char c, boolean throwsException) throws EncodeException { 761 if (sCharsToGsmTables[0].get(c, -1) != -1) { 762 return 1; 763 } 764 765 if (sCharsToShiftTables[0].get(c, -1) != -1) { 766 return 2; 767 } 768 769 if (throwsException) { 770 throw new EncodeException(c); 771 } else { 772 // count as a space char 773 return 1; 774 } 775 } 776 777 public static boolean isGsmSeptets(char c) { 778 if (sCharsToGsmTables[0].get(c, -1) != -1) { 779 return true; 780 } 781 782 if (sCharsToShiftTables[0].get(c, -1) != -1) { 783 return true; 784 } 785 786 return false; 787 } 788 789 /** 790 * Returns the count of 7-bit GSM alphabet characters needed 791 * to represent this string, using the specified 7-bit language table 792 * and extension table (0 for GSM default tables). 793 * @param s the Unicode string that will be encoded 794 * @param use7bitOnly allow using space in place of unencodable character if true, 795 * otherwise, return -1 if any characters are unencodable 796 * @param languageTable the 7 bit language table, or 0 for the default GSM alphabet 797 * @param languageShiftTable the 7 bit single shift language table, or 0 for the default 798 * GSM extension table 799 * @return the septet count for s using the specified language tables, or -1 if any 800 * characters are unencodable and use7bitOnly is false 801 */ 802 public static int countGsmSeptetsUsingTables(CharSequence s, boolean use7bitOnly, 803 int languageTable, int languageShiftTable) { 804 int count = 0; 805 int sz = s.length(); 806 SparseIntArray charToLanguageTable = sCharsToGsmTables[languageTable]; 807 SparseIntArray charToShiftTable = sCharsToShiftTables[languageShiftTable]; 808 for (int i = 0; i < sz; i++) { 809 char c = s.charAt(i); 810 if (c == GSM_EXTENDED_ESCAPE) { 811 Rlog.w(TAG, "countGsmSeptets() string contains Escape character, skipping."); 812 continue; 813 } 814 if (charToLanguageTable.get(c, -1) != -1) { 815 count++; 816 } else if (charToShiftTable.get(c, -1) != -1) { 817 count += 2; // escape + shift table index 818 } else if (use7bitOnly) { 819 count++; // encode as space 820 } else { 821 return -1; // caller must check for this case 822 } 823 } 824 return count; 825 } 826 827 /** 828 * Returns the count of 7-bit GSM alphabet characters 829 * needed to represent this string, and the language table and 830 * language shift table used to achieve this result. 831 * For multi-part text messages, each message part may use its 832 * own language table encoding as specified in the message header 833 * for that message. However, this method will only return the 834 * optimal encoding for the message as a whole. When the individual 835 * pieces are encoded, a more optimal encoding may be chosen for each 836 * piece of the message, but the message will be split into pieces 837 * based on the encoding chosen for the message as a whole. 838 * @param s the Unicode string that will be encoded 839 * @param use7bitOnly allow using space in place of unencodable character if true, 840 * using the language table pair with the fewest unencodable characters 841 * @return a TextEncodingDetails object containing the message and 842 * character counts for the most efficient 7-bit encoding, 843 * or null if there are no suitable language tables to encode the string. 844 */ 845 public static TextEncodingDetails 846 countGsmSeptets(CharSequence s, boolean use7bitOnly) { 847 // Load enabled language tables from config.xml, including any MCC overlays 848 if (!sDisableCountryEncodingCheck) { 849 enableCountrySpecificEncodings(); 850 } 851 // fast path for common case where no national language shift tables are enabled 852 if (sEnabledSingleShiftTables.length + sEnabledLockingShiftTables.length == 0) { 853 TextEncodingDetails ted = new TextEncodingDetails(); 854 int septets = GsmAlphabet.countGsmSeptetsUsingTables(s, use7bitOnly, 0, 0); 855 if (septets == -1) { 856 return null; 857 } 858 ted.codeUnitSize = SmsConstants.ENCODING_7BIT; 859 ted.codeUnitCount = septets; 860 if (septets > SmsConstants.MAX_USER_DATA_SEPTETS) { 861 ted.msgCount = (septets + (SmsConstants.MAX_USER_DATA_SEPTETS_WITH_HEADER - 1)) / 862 SmsConstants.MAX_USER_DATA_SEPTETS_WITH_HEADER; 863 ted.codeUnitsRemaining = (ted.msgCount * 864 SmsConstants.MAX_USER_DATA_SEPTETS_WITH_HEADER) - septets; 865 } else { 866 ted.msgCount = 1; 867 ted.codeUnitsRemaining = SmsConstants.MAX_USER_DATA_SEPTETS - septets; 868 } 869 return ted; 870 } 871 872 int maxSingleShiftCode = sHighestEnabledSingleShiftCode; 873 List<LanguagePairCount> lpcList = new ArrayList<LanguagePairCount>( 874 sEnabledLockingShiftTables.length + 1); 875 876 // Always add default GSM 7-bit alphabet table 877 lpcList.add(new LanguagePairCount(0)); 878 for (int i : sEnabledLockingShiftTables) { 879 // Avoid adding default table twice in case 0 is in the list of allowed tables 880 if (i != 0 && !sLanguageTables[i].isEmpty()) { 881 lpcList.add(new LanguagePairCount(i)); 882 } 883 } 884 885 int sz = s.length(); 886 // calculate septet count for each valid table / shift table pair 887 for (int i = 0; i < sz && !lpcList.isEmpty(); i++) { 888 char c = s.charAt(i); 889 if (c == GSM_EXTENDED_ESCAPE) { 890 Rlog.w(TAG, "countGsmSeptets() string contains Escape character, ignoring!"); 891 continue; 892 } 893 // iterate through enabled locking shift tables 894 for (LanguagePairCount lpc : lpcList) { 895 int tableIndex = sCharsToGsmTables[lpc.languageCode].get(c, -1); 896 if (tableIndex == -1) { 897 // iterate through single shift tables for this locking table 898 for (int table = 0; table <= maxSingleShiftCode; table++) { 899 if (lpc.septetCounts[table] != -1) { 900 int shiftTableIndex = sCharsToShiftTables[table].get(c, -1); 901 if (shiftTableIndex == -1) { 902 if (use7bitOnly) { 903 // can't encode char, use space instead 904 lpc.septetCounts[table]++; 905 lpc.unencodableCounts[table]++; 906 } else { 907 // can't encode char, remove language pair from list 908 lpc.septetCounts[table] = -1; 909 } 910 } else { 911 // encode as Escape + index into shift table 912 lpc.septetCounts[table] += 2; 913 } 914 } 915 } 916 } else { 917 // encode as index into locking shift table for all pairs 918 for (int table = 0; table <= maxSingleShiftCode; table++) { 919 if (lpc.septetCounts[table] != -1) { 920 lpc.septetCounts[table]++; 921 } 922 } 923 } 924 } 925 } 926 927 // find the least cost encoding (lowest message count and most code units remaining) 928 TextEncodingDetails ted = new TextEncodingDetails(); 929 ted.msgCount = Integer.MAX_VALUE; 930 ted.codeUnitSize = SmsConstants.ENCODING_7BIT; 931 int minUnencodableCount = Integer.MAX_VALUE; 932 for (LanguagePairCount lpc : lpcList) { 933 for (int shiftTable = 0; shiftTable <= maxSingleShiftCode; shiftTable++) { 934 int septets = lpc.septetCounts[shiftTable]; 935 if (septets == -1) { 936 continue; 937 } 938 int udhLength; 939 if (lpc.languageCode != 0 && shiftTable != 0) { 940 udhLength = UDH_SEPTET_COST_LENGTH + UDH_SEPTET_COST_TWO_SHIFT_TABLES; 941 } else if (lpc.languageCode != 0 || shiftTable != 0) { 942 udhLength = UDH_SEPTET_COST_LENGTH + UDH_SEPTET_COST_ONE_SHIFT_TABLE; 943 } else { 944 udhLength = 0; 945 } 946 int msgCount; 947 int septetsRemaining; 948 if (septets + udhLength > SmsConstants.MAX_USER_DATA_SEPTETS) { 949 if (udhLength == 0) { 950 udhLength = UDH_SEPTET_COST_LENGTH; 951 } 952 udhLength += UDH_SEPTET_COST_CONCATENATED_MESSAGE; 953 int septetsPerMessage = SmsConstants.MAX_USER_DATA_SEPTETS - udhLength; 954 msgCount = (septets + septetsPerMessage - 1) / septetsPerMessage; 955 septetsRemaining = (msgCount * septetsPerMessage) - septets; 956 } else { 957 msgCount = 1; 958 septetsRemaining = SmsConstants.MAX_USER_DATA_SEPTETS - udhLength - septets; 959 } 960 // for 7-bit only mode, use language pair with the least unencodable chars 961 int unencodableCount = lpc.unencodableCounts[shiftTable]; 962 if (use7bitOnly && unencodableCount > minUnencodableCount) { 963 continue; 964 } 965 if ((use7bitOnly && unencodableCount < minUnencodableCount) 966 || msgCount < ted.msgCount || (msgCount == ted.msgCount 967 && septetsRemaining > ted.codeUnitsRemaining)) { 968 minUnencodableCount = unencodableCount; 969 ted.msgCount = msgCount; 970 ted.codeUnitCount = septets; 971 ted.codeUnitsRemaining = septetsRemaining; 972 ted.languageTable = lpc.languageCode; 973 ted.languageShiftTable = shiftTable; 974 } 975 } 976 } 977 978 if (ted.msgCount == Integer.MAX_VALUE) { 979 return null; 980 } 981 982 return ted; 983 } 984 985 /** 986 * Returns the index into <code>s</code> of the first character 987 * after <code>limit</code> septets have been reached, starting at 988 * index <code>start</code>. This is used when dividing messages 989 * into units within the SMS message size limit. 990 * 991 * @param s source string 992 * @param start index of where to start counting septets 993 * @param limit maximum septets to include, 994 * e.g. <code>MAX_USER_DATA_SEPTETS</code> 995 * @param langTable the 7 bit character table to use (0 for default GSM 7-bit alphabet) 996 * @param langShiftTable the 7 bit shift table to use (0 for default GSM extension table) 997 * @return index of first character that won't fit, or the length 998 * of the entire string if everything fits 999 */ 1000 @UnsupportedAppUsage 1001 public static int 1002 findGsmSeptetLimitIndex(String s, int start, int limit, int langTable, int langShiftTable) { 1003 int accumulator = 0; 1004 int size = s.length(); 1005 1006 SparseIntArray charToLangTable = sCharsToGsmTables[langTable]; 1007 SparseIntArray charToLangShiftTable = sCharsToShiftTables[langShiftTable]; 1008 for (int i = start; i < size; i++) { 1009 int encodedSeptet = charToLangTable.get(s.charAt(i), -1); 1010 if (encodedSeptet == -1) { 1011 encodedSeptet = charToLangShiftTable.get(s.charAt(i), -1); 1012 if (encodedSeptet == -1) { 1013 // char not found, assume we're replacing with space 1014 accumulator++; 1015 } else { 1016 accumulator += 2; // escape character + shift table index 1017 } 1018 } else { 1019 accumulator++; 1020 } 1021 if (accumulator > limit) { 1022 return i; 1023 } 1024 } 1025 return size; 1026 } 1027 1028 /** 1029 * Modify the array of enabled national language single shift tables for SMS 1030 * encoding. This is used for unit testing, but could also be used to 1031 * modify the enabled encodings based on the active MCC/MNC, for example. 1032 * 1033 * @param tables the new list of enabled single shift tables 1034 */ 1035 public static synchronized void setEnabledSingleShiftTables(int[] tables) { 1036 sEnabledSingleShiftTables = tables; 1037 sDisableCountryEncodingCheck = true; 1038 1039 if (tables.length > 0) { 1040 sHighestEnabledSingleShiftCode = tables[tables.length - 1]; 1041 } else { 1042 sHighestEnabledSingleShiftCode = 0; 1043 } 1044 } 1045 1046 /** 1047 * Modify the array of enabled national language locking shift tables for SMS 1048 * encoding. This is used for unit testing, but could also be used to 1049 * modify the enabled encodings based on the active MCC/MNC, for example. 1050 * 1051 * @param tables the new list of enabled locking shift tables 1052 */ 1053 public static synchronized void setEnabledLockingShiftTables(int[] tables) { 1054 sEnabledLockingShiftTables = tables; 1055 sDisableCountryEncodingCheck = true; 1056 } 1057 1058 /** 1059 * Return the array of enabled national language single shift tables for SMS 1060 * encoding. This is used for unit testing. The returned array is not a copy, so 1061 * the caller should be careful not to modify it. 1062 * 1063 * @return the list of enabled single shift tables 1064 */ 1065 public static synchronized int[] getEnabledSingleShiftTables() { 1066 return sEnabledSingleShiftTables; 1067 } 1068 1069 /** 1070 * Return the array of enabled national language locking shift tables for SMS 1071 * encoding. This is used for unit testing. The returned array is not a copy, so 1072 * the caller should be careful not to modify it. 1073 * 1074 * @return the list of enabled locking shift tables 1075 */ 1076 public static synchronized int[] getEnabledLockingShiftTables() { 1077 return sEnabledLockingShiftTables; 1078 } 1079 1080 /** 1081 * Enable country-specific language tables from MCC-specific overlays. 1082 * @context the context to use to get the TelephonyManager 1083 */ 1084 private static void enableCountrySpecificEncodings() { 1085 Resources r = Resources.getSystem(); 1086 // See comments in frameworks/base/core/res/res/values/config.xml for allowed values 1087 sEnabledSingleShiftTables = r.getIntArray(R.array.config_sms_enabled_single_shift_tables); 1088 sEnabledLockingShiftTables = r.getIntArray(R.array.config_sms_enabled_locking_shift_tables); 1089 1090 if (sEnabledSingleShiftTables.length > 0) { 1091 sHighestEnabledSingleShiftCode = 1092 sEnabledSingleShiftTables[sEnabledSingleShiftTables.length-1]; 1093 } else { 1094 sHighestEnabledSingleShiftCode = 0; 1095 } 1096 } 1097 1098 /** Reverse mapping from Unicode characters to indexes into language tables. */ 1099 @UnsupportedAppUsage 1100 private static final SparseIntArray[] sCharsToGsmTables; 1101 1102 /** Reverse mapping from Unicode characters to indexes into language shift tables. */ 1103 @UnsupportedAppUsage 1104 private static final SparseIntArray[] sCharsToShiftTables; 1105 1106 /** OEM configured list of enabled national language single shift tables for encoding. */ 1107 @UnsupportedAppUsage 1108 private static int[] sEnabledSingleShiftTables; 1109 1110 /** OEM configured list of enabled national language locking shift tables for encoding. */ 1111 @UnsupportedAppUsage 1112 private static int[] sEnabledLockingShiftTables; 1113 1114 /** Highest language code to include in array of single shift counters. */ 1115 @UnsupportedAppUsage 1116 private static int sHighestEnabledSingleShiftCode; 1117 1118 /** Flag to bypass check for country-specific overlays (for test cases only). */ 1119 private static boolean sDisableCountryEncodingCheck = false; 1120 1121 /** 1122 * Septet counter for a specific locking shift table and all of 1123 * the single shift tables that it can be paired with. 1124 */ 1125 private static class LanguagePairCount { 1126 @UnsupportedAppUsage 1127 final int languageCode; 1128 @UnsupportedAppUsage 1129 final int[] septetCounts; 1130 @UnsupportedAppUsage 1131 final int[] unencodableCounts; 1132 @UnsupportedAppUsage 1133 LanguagePairCount(int code) { 1134 this.languageCode = code; 1135 int maxSingleShiftCode = sHighestEnabledSingleShiftCode; 1136 septetCounts = new int[maxSingleShiftCode + 1]; 1137 unencodableCounts = new int[maxSingleShiftCode + 1]; 1138 // set counters for disabled single shift tables to -1 1139 // (GSM default extension table index 0 is always enabled) 1140 for (int i = 1, tableOffset = 0; i <= maxSingleShiftCode; i++) { 1141 if (sEnabledSingleShiftTables[tableOffset] == i) { 1142 tableOffset++; 1143 } else { 1144 septetCounts[i] = -1; // disabled 1145 } 1146 } 1147 // exclude Turkish locking + Turkish single shift table and 1148 // Portuguese locking + Spanish single shift table (these 1149 // combinations will never be optimal for any input). 1150 if (code == 1 && maxSingleShiftCode >= 1) { 1151 septetCounts[1] = -1; // Turkish + Turkish 1152 } else if (code == 3 && maxSingleShiftCode >= 2) { 1153 septetCounts[2] = -1; // Portuguese + Spanish 1154 } 1155 } 1156 } 1157 1158 /** 1159 * GSM default 7 bit alphabet plus national language locking shift character tables. 1160 * Comment lines above strings indicate the lower four bits of the table position. 1161 */ 1162 @UnsupportedAppUsage 1163 private static final String[] sLanguageTables = { 1164 /* 3GPP TS 23.038 V9.1.1 section 6.2.1 - GSM 7 bit Default Alphabet 1165 01.....23.....4.....5.....6.....7.....8.....9.....A.B.....C.....D.E.....F.....0.....1 */ 1166 "@\u00a3$\u00a5\u00e8\u00e9\u00f9\u00ec\u00f2\u00c7\n\u00d8\u00f8\r\u00c5\u00e5\u0394_" 1167 // 2.....3.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E..... 1168 + "\u03a6\u0393\u039b\u03a9\u03a0\u03a8\u03a3\u0398\u039e\uffff\u00c6\u00e6\u00df" 1169 // F.....012.34.....56789ABCDEF0123456789ABCDEF0.....123456789ABCDEF0123456789A 1170 + "\u00c9 !\"#\u00a4%&'()*+,-./0123456789:;<=>?\u00a1ABCDEFGHIJKLMNOPQRSTUVWXYZ" 1171 // B.....C.....D.....E.....F.....0.....123456789ABCDEF0123456789AB.....C.....D..... 1172 + "\u00c4\u00d6\u00d1\u00dc\u00a7\u00bfabcdefghijklmnopqrstuvwxyz\u00e4\u00f6\u00f1" 1173 // E.....F..... 1174 + "\u00fc\u00e0", 1175 1176 /* A.3.1 Turkish National Language Locking Shift Table 1177 01.....23.....4.....5.....6.....7.....8.....9.....A.B.....C.....D.E.....F.....0.....1 */ 1178 "@\u00a3$\u00a5\u20ac\u00e9\u00f9\u0131\u00f2\u00c7\n\u011e\u011f\r\u00c5\u00e5\u0394_" 1179 // 2.....3.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E..... 1180 + "\u03a6\u0393\u039b\u03a9\u03a0\u03a8\u03a3\u0398\u039e\uffff\u015e\u015f\u00df" 1181 // F.....012.34.....56789ABCDEF0123456789ABCDEF0.....123456789ABCDEF0123456789A 1182 + "\u00c9 !\"#\u00a4%&'()*+,-./0123456789:;<=>?\u0130ABCDEFGHIJKLMNOPQRSTUVWXYZ" 1183 // B.....C.....D.....E.....F.....0.....123456789ABCDEF0123456789AB.....C.....D..... 1184 + "\u00c4\u00d6\u00d1\u00dc\u00a7\u00e7abcdefghijklmnopqrstuvwxyz\u00e4\u00f6\u00f1" 1185 // E.....F..... 1186 + "\u00fc\u00e0", 1187 1188 /* A.3.2 Void (no locking shift table for Spanish) */ 1189 "", 1190 1191 /* A.3.3 Portuguese National Language Locking Shift Table 1192 01.....23.....4.....5.....6.....7.....8.....9.....A.B.....C.....D.E.....F.....0.....1 */ 1193 "@\u00a3$\u00a5\u00ea\u00e9\u00fa\u00ed\u00f3\u00e7\n\u00d4\u00f4\r\u00c1\u00e1\u0394_" 1194 // 2.....3.....4.....5.....67.8.....9.....AB.....C.....D.....E.....F.....012.34..... 1195 + "\u00aa\u00c7\u00c0\u221e^\\\u20ac\u00d3|\uffff\u00c2\u00e2\u00ca\u00c9 !\"#\u00ba" 1196 // 56789ABCDEF0123456789ABCDEF0.....123456789ABCDEF0123456789AB.....C.....D.....E..... 1197 + "%&'()*+,-./0123456789:;<=>?\u00cdABCDEFGHIJKLMNOPQRSTUVWXYZ\u00c3\u00d5\u00da\u00dc" 1198 // F.....0123456789ABCDEF0123456789AB.....C.....DE.....F..... 1199 + "\u00a7~abcdefghijklmnopqrstuvwxyz\u00e3\u00f5`\u00fc\u00e0", 1200 1201 /* A.3.4 Bengali National Language Locking Shift Table 1202 0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.B.....CD.EF.....0..... */ 1203 "\u0981\u0982\u0983\u0985\u0986\u0987\u0988\u0989\u098a\u098b\n\u098c \r \u098f\u0990" 1204 // 123.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E.....F..... 1205 + " \u0993\u0994\u0995\u0996\u0997\u0998\u0999\u099a\uffff\u099b\u099c\u099d\u099e" 1206 // 012.....3.....4.....5.....6.....7.....89A.....B.....CD.....EF.....0123456789ABC 1207 + " !\u099f\u09a0\u09a1\u09a2\u09a3\u09a4)(\u09a5\u09a6,\u09a7.\u09a80123456789:; " 1208 // D.....E.....F0.....1.....2.....3.....4.....56.....789A.....B.....C.....D..... 1209 + "\u09aa\u09ab?\u09ac\u09ad\u09ae\u09af\u09b0 \u09b2 \u09b6\u09b7\u09b8\u09b9" 1210 // E.....F.....0.....1.....2.....3.....4.....5.....6.....789.....A.....BCD.....E..... 1211 + "\u09bc\u09bd\u09be\u09bf\u09c0\u09c1\u09c2\u09c3\u09c4 \u09c7\u09c8 \u09cb\u09cc" 1212 // F.....0.....123456789ABCDEF0123456789AB.....C.....D.....E.....F..... 1213 + "\u09cd\u09ceabcdefghijklmnopqrstuvwxyz\u09d7\u09dc\u09dd\u09f0\u09f1", 1214 1215 /* A.3.5 Gujarati National Language Locking Shift Table 1216 0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.B.....C.....D.EF.....0.....*/ 1217 "\u0a81\u0a82\u0a83\u0a85\u0a86\u0a87\u0a88\u0a89\u0a8a\u0a8b\n\u0a8c\u0a8d\r \u0a8f\u0a90" 1218 // 1.....23.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E..... 1219 + "\u0a91 \u0a93\u0a94\u0a95\u0a96\u0a97\u0a98\u0a99\u0a9a\uffff\u0a9b\u0a9c\u0a9d" 1220 // F.....012.....3.....4.....5.....6.....7.....89A.....B.....CD.....EF.....0123456789AB 1221 + "\u0a9e !\u0a9f\u0aa0\u0aa1\u0aa2\u0aa3\u0aa4)(\u0aa5\u0aa6,\u0aa7.\u0aa80123456789:;" 1222 // CD.....E.....F0.....1.....2.....3.....4.....56.....7.....89.....A.....B.....C..... 1223 + " \u0aaa\u0aab?\u0aac\u0aad\u0aae\u0aaf\u0ab0 \u0ab2\u0ab3 \u0ab5\u0ab6\u0ab7\u0ab8" 1224 // D.....E.....F.....0.....1.....2.....3.....4.....5.....6.....7.....89.....A..... 1225 + "\u0ab9\u0abc\u0abd\u0abe\u0abf\u0ac0\u0ac1\u0ac2\u0ac3\u0ac4\u0ac5 \u0ac7\u0ac8" 1226 // B.....CD.....E.....F.....0.....123456789ABCDEF0123456789AB.....C.....D.....E..... 1227 + "\u0ac9 \u0acb\u0acc\u0acd\u0ad0abcdefghijklmnopqrstuvwxyz\u0ae0\u0ae1\u0ae2\u0ae3" 1228 // F..... 1229 + "\u0af1", 1230 1231 /* A.3.6 Hindi National Language Locking Shift Table 1232 0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.B.....C.....D.E.....F.....*/ 1233 "\u0901\u0902\u0903\u0905\u0906\u0907\u0908\u0909\u090a\u090b\n\u090c\u090d\r\u090e\u090f" 1234 // 0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D..... 1235 + "\u0910\u0911\u0912\u0913\u0914\u0915\u0916\u0917\u0918\u0919\u091a\uffff\u091b\u091c" 1236 // E.....F.....012.....3.....4.....5.....6.....7.....89A.....B.....CD.....EF.....012345 1237 + "\u091d\u091e !\u091f\u0920\u0921\u0922\u0923\u0924)(\u0925\u0926,\u0927.\u0928012345" 1238 // 6789ABC.....D.....E.....F0.....1.....2.....3.....4.....5.....6.....7.....8..... 1239 + "6789:;\u0929\u092a\u092b?\u092c\u092d\u092e\u092f\u0930\u0931\u0932\u0933\u0934" 1240 // 9.....A.....B.....C.....D.....E.....F.....0.....1.....2.....3.....4.....5.....6..... 1241 + "\u0935\u0936\u0937\u0938\u0939\u093c\u093d\u093e\u093f\u0940\u0941\u0942\u0943\u0944" 1242 // 7.....8.....9.....A.....B.....C.....D.....E.....F.....0.....123456789ABCDEF012345678 1243 + "\u0945\u0946\u0947\u0948\u0949\u094a\u094b\u094c\u094d\u0950abcdefghijklmnopqrstuvwx" 1244 // 9AB.....C.....D.....E.....F..... 1245 + "yz\u0972\u097b\u097c\u097e\u097f", 1246 1247 /* A.3.7 Kannada National Language Locking Shift Table 1248 NOTE: TS 23.038 V9.1.1 shows code 0x24 as \u0caa, corrected to \u0ca1 (typo) 1249 01.....2.....3.....4.....5.....6.....7.....8.....9.....A.B.....CD.E.....F.....0.....1 */ 1250 " \u0c82\u0c83\u0c85\u0c86\u0c87\u0c88\u0c89\u0c8a\u0c8b\n\u0c8c \r\u0c8e\u0c8f\u0c90 " 1251 // 2.....3.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E.....F..... 1252 + "\u0c92\u0c93\u0c94\u0c95\u0c96\u0c97\u0c98\u0c99\u0c9a\uffff\u0c9b\u0c9c\u0c9d\u0c9e" 1253 // 012.....3.....4.....5.....6.....7.....89A.....B.....CD.....EF.....0123456789ABC 1254 + " !\u0c9f\u0ca0\u0ca1\u0ca2\u0ca3\u0ca4)(\u0ca5\u0ca6,\u0ca7.\u0ca80123456789:; " 1255 // D.....E.....F0.....1.....2.....3.....4.....5.....6.....7.....89.....A.....B..... 1256 + "\u0caa\u0cab?\u0cac\u0cad\u0cae\u0caf\u0cb0\u0cb1\u0cb2\u0cb3 \u0cb5\u0cb6\u0cb7" 1257 // C.....D.....E.....F.....0.....1.....2.....3.....4.....5.....6.....78.....9..... 1258 + "\u0cb8\u0cb9\u0cbc\u0cbd\u0cbe\u0cbf\u0cc0\u0cc1\u0cc2\u0cc3\u0cc4 \u0cc6\u0cc7" 1259 // A.....BC.....D.....E.....F.....0.....123456789ABCDEF0123456789AB.....C.....D..... 1260 + "\u0cc8 \u0cca\u0ccb\u0ccc\u0ccd\u0cd5abcdefghijklmnopqrstuvwxyz\u0cd6\u0ce0\u0ce1" 1261 // E.....F..... 1262 + "\u0ce2\u0ce3", 1263 1264 /* A.3.8 Malayalam National Language Locking Shift Table 1265 01.....2.....3.....4.....5.....6.....7.....8.....9.....A.B.....CD.E.....F.....0.....1 */ 1266 " \u0d02\u0d03\u0d05\u0d06\u0d07\u0d08\u0d09\u0d0a\u0d0b\n\u0d0c \r\u0d0e\u0d0f\u0d10 " 1267 // 2.....3.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E.....F..... 1268 + "\u0d12\u0d13\u0d14\u0d15\u0d16\u0d17\u0d18\u0d19\u0d1a\uffff\u0d1b\u0d1c\u0d1d\u0d1e" 1269 // 012.....3.....4.....5.....6.....7.....89A.....B.....CD.....EF.....0123456789ABC 1270 + " !\u0d1f\u0d20\u0d21\u0d22\u0d23\u0d24)(\u0d25\u0d26,\u0d27.\u0d280123456789:; " 1271 // D.....E.....F0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A..... 1272 + "\u0d2a\u0d2b?\u0d2c\u0d2d\u0d2e\u0d2f\u0d30\u0d31\u0d32\u0d33\u0d34\u0d35\u0d36" 1273 // B.....C.....D.....EF.....0.....1.....2.....3.....4.....5.....6.....78.....9..... 1274 + "\u0d37\u0d38\u0d39 \u0d3d\u0d3e\u0d3f\u0d40\u0d41\u0d42\u0d43\u0d44 \u0d46\u0d47" 1275 // A.....BC.....D.....E.....F.....0.....123456789ABCDEF0123456789AB.....C.....D..... 1276 + "\u0d48 \u0d4a\u0d4b\u0d4c\u0d4d\u0d57abcdefghijklmnopqrstuvwxyz\u0d60\u0d61\u0d62" 1277 // E.....F..... 1278 + "\u0d63\u0d79", 1279 1280 /* A.3.9 Oriya National Language Locking Shift Table 1281 0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.B.....CD.EF.....0.....12 */ 1282 "\u0b01\u0b02\u0b03\u0b05\u0b06\u0b07\u0b08\u0b09\u0b0a\u0b0b\n\u0b0c \r \u0b0f\u0b10 " 1283 // 3.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E.....F.....01 1284 + "\u0b13\u0b14\u0b15\u0b16\u0b17\u0b18\u0b19\u0b1a\uffff\u0b1b\u0b1c\u0b1d\u0b1e !" 1285 // 2.....3.....4.....5.....6.....7.....89A.....B.....CD.....EF.....0123456789ABCD..... 1286 + "\u0b1f\u0b20\u0b21\u0b22\u0b23\u0b24)(\u0b25\u0b26,\u0b27.\u0b280123456789:; \u0b2a" 1287 // E.....F0.....1.....2.....3.....4.....56.....7.....89.....A.....B.....C.....D..... 1288 + "\u0b2b?\u0b2c\u0b2d\u0b2e\u0b2f\u0b30 \u0b32\u0b33 \u0b35\u0b36\u0b37\u0b38\u0b39" 1289 // E.....F.....0.....1.....2.....3.....4.....5.....6.....789.....A.....BCD.....E..... 1290 + "\u0b3c\u0b3d\u0b3e\u0b3f\u0b40\u0b41\u0b42\u0b43\u0b44 \u0b47\u0b48 \u0b4b\u0b4c" 1291 // F.....0.....123456789ABCDEF0123456789AB.....C.....D.....E.....F..... 1292 + "\u0b4d\u0b56abcdefghijklmnopqrstuvwxyz\u0b57\u0b60\u0b61\u0b62\u0b63", 1293 1294 /* A.3.10 Punjabi National Language Locking Shift Table 1295 0.....1.....2.....3.....4.....5.....6.....7.....8.....9A.BCD.EF.....0.....123.....4.....*/ 1296 "\u0a01\u0a02\u0a03\u0a05\u0a06\u0a07\u0a08\u0a09\u0a0a \n \r \u0a0f\u0a10 \u0a13\u0a14" 1297 // 5.....6.....7.....8.....9.....A.....B.....C.....D.....E.....F.....012.....3..... 1298 + "\u0a15\u0a16\u0a17\u0a18\u0a19\u0a1a\uffff\u0a1b\u0a1c\u0a1d\u0a1e !\u0a1f\u0a20" 1299 // 4.....5.....6.....7.....89A.....B.....CD.....EF.....0123456789ABCD.....E.....F0..... 1300 + "\u0a21\u0a22\u0a23\u0a24)(\u0a25\u0a26,\u0a27.\u0a280123456789:; \u0a2a\u0a2b?\u0a2c" 1301 // 1.....2.....3.....4.....56.....7.....89.....A.....BC.....D.....E.....F0.....1..... 1302 + "\u0a2d\u0a2e\u0a2f\u0a30 \u0a32\u0a33 \u0a35\u0a36 \u0a38\u0a39\u0a3c \u0a3e\u0a3f" 1303 // 2.....3.....4.....56789.....A.....BCD.....E.....F.....0.....123456789ABCDEF012345678 1304 + "\u0a40\u0a41\u0a42 \u0a47\u0a48 \u0a4b\u0a4c\u0a4d\u0a51abcdefghijklmnopqrstuvwx" 1305 // 9AB.....C.....D.....E.....F..... 1306 + "yz\u0a70\u0a71\u0a72\u0a73\u0a74", 1307 1308 /* A.3.11 Tamil National Language Locking Shift Table 1309 01.....2.....3.....4.....5.....6.....7.....8.....9A.BCD.E.....F.....0.....12.....3..... */ 1310 " \u0b82\u0b83\u0b85\u0b86\u0b87\u0b88\u0b89\u0b8a \n \r\u0b8e\u0b8f\u0b90 \u0b92\u0b93" 1311 // 4.....5.....6789.....A.....B.....CD.....EF.....012.....3456.....7.....89ABCDEF..... 1312 + "\u0b94\u0b95 \u0b99\u0b9a\uffff \u0b9c \u0b9e !\u0b9f \u0ba3\u0ba4)( , .\u0ba8" 1313 // 0123456789ABC.....D.....EF012.....3.....4.....5.....6.....7.....8.....9.....A..... 1314 + "0123456789:;\u0ba9\u0baa ? \u0bae\u0baf\u0bb0\u0bb1\u0bb2\u0bb3\u0bb4\u0bb5\u0bb6" 1315 // B.....C.....D.....EF0.....1.....2.....3.....4.....5678.....9.....A.....BC.....D..... 1316 + "\u0bb7\u0bb8\u0bb9 \u0bbe\u0bbf\u0bc0\u0bc1\u0bc2 \u0bc6\u0bc7\u0bc8 \u0bca\u0bcb" 1317 // E.....F.....0.....123456789ABCDEF0123456789AB.....C.....D.....E.....F..... 1318 + "\u0bcc\u0bcd\u0bd0abcdefghijklmnopqrstuvwxyz\u0bd7\u0bf0\u0bf1\u0bf2\u0bf9", 1319 1320 /* A.3.12 Telugu National Language Locking Shift Table 1321 0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.B.....CD.E.....F.....0.....*/ 1322 "\u0c01\u0c02\u0c03\u0c05\u0c06\u0c07\u0c08\u0c09\u0c0a\u0c0b\n\u0c0c \r\u0c0e\u0c0f\u0c10" 1323 // 12.....3.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E..... 1324 + " \u0c12\u0c13\u0c14\u0c15\u0c16\u0c17\u0c18\u0c19\u0c1a\uffff\u0c1b\u0c1c\u0c1d" 1325 // F.....012.....3.....4.....5.....6.....7.....89A.....B.....CD.....EF.....0123456789AB 1326 + "\u0c1e !\u0c1f\u0c20\u0c21\u0c22\u0c23\u0c24)(\u0c25\u0c26,\u0c27.\u0c280123456789:;" 1327 // CD.....E.....F0.....1.....2.....3.....4.....5.....6.....7.....89.....A.....B..... 1328 + " \u0c2a\u0c2b?\u0c2c\u0c2d\u0c2e\u0c2f\u0c30\u0c31\u0c32\u0c33 \u0c35\u0c36\u0c37" 1329 // C.....D.....EF.....0.....1.....2.....3.....4.....5.....6.....78.....9.....A.....B 1330 + "\u0c38\u0c39 \u0c3d\u0c3e\u0c3f\u0c40\u0c41\u0c42\u0c43\u0c44 \u0c46\u0c47\u0c48 " 1331 // C.....D.....E.....F.....0.....123456789ABCDEF0123456789AB.....C.....D.....E..... 1332 + "\u0c4a\u0c4b\u0c4c\u0c4d\u0c55abcdefghijklmnopqrstuvwxyz\u0c56\u0c60\u0c61\u0c62" 1333 // F..... 1334 + "\u0c63", 1335 1336 /* A.3.13 Urdu National Language Locking Shift Table 1337 0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.B.....C.....D.E.....F.....*/ 1338 "\u0627\u0622\u0628\u067b\u0680\u067e\u06a6\u062a\u06c2\u067f\n\u0679\u067d\r\u067a\u067c" 1339 // 0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D..... 1340 + "\u062b\u062c\u0681\u0684\u0683\u0685\u0686\u0687\u062d\u062e\u062f\uffff\u068c\u0688" 1341 // E.....F.....012.....3.....4.....5.....6.....7.....89A.....B.....CD.....EF.....012345 1342 + "\u0689\u068a !\u068f\u068d\u0630\u0631\u0691\u0693)(\u0699\u0632,\u0696.\u0698012345" 1343 // 6789ABC.....D.....E.....F0.....1.....2.....3.....4.....5.....6.....7.....8..... 1344 + "6789:;\u069a\u0633\u0634?\u0635\u0636\u0637\u0638\u0639\u0641\u0642\u06a9\u06aa" 1345 // 9.....A.....B.....C.....D.....E.....F.....0.....1.....2.....3.....4.....5.....6..... 1346 + "\u06ab\u06af\u06b3\u06b1\u0644\u0645\u0646\u06ba\u06bb\u06bc\u0648\u06c4\u06d5\u06c1" 1347 // 7.....8.....9.....A.....B.....C.....D.....E.....F.....0.....123456789ABCDEF012345678 1348 + "\u06be\u0621\u06cc\u06d0\u06d2\u064d\u0650\u064f\u0657\u0654abcdefghijklmnopqrstuvwx" 1349 // 9AB.....C.....D.....E.....F..... 1350 + "yz\u0655\u0651\u0653\u0656\u0670" 1351 }; 1352 1353 /** 1354 * GSM default extension table plus national language single shift character tables. 1355 */ 1356 @UnsupportedAppUsage 1357 private static final String[] sLanguageShiftTables = new String[]{ 1358 /* 6.2.1.1 GSM 7 bit Default Alphabet Extension Table 1359 0123456789A.....BCDEF0123456789ABCDEF0123456789ABCDEF.0123456789ABCDEF0123456789ABCDEF */ 1360 " \u000c ^ {} \\ [~] | " 1361 // 0123456789ABCDEF012345.....6789ABCDEF0123456789ABCDEF 1362 + " \u20ac ", 1363 1364 /* A.2.1 Turkish National Language Single Shift Table 1365 0123456789A.....BCDEF0123456789ABCDEF0123456789ABCDEF.0123456789ABCDEF01234567.....8 */ 1366 " \u000c ^ {} \\ [~] | \u011e " 1367 // 9.....ABCDEF0123.....456789ABCDEF0123.....45.....67.....89.....ABCDEF0123..... 1368 + "\u0130 \u015e \u00e7 \u20ac \u011f \u0131 \u015f" 1369 // 456789ABCDEF 1370 + " ", 1371 1372 /* A.2.2 Spanish National Language Single Shift Table 1373 0123456789.....A.....BCDEF0123456789ABCDEF0123456789ABCDEF.0123456789ABCDEF01.....23 */ 1374 " \u00e7\u000c ^ {} \\ [~] |\u00c1 " 1375 // 456789.....ABCDEF.....012345.....6789ABCDEF01.....2345.....6789.....ABCDEF.....012 1376 + " \u00cd \u00d3 \u00da \u00e1 \u20ac \u00ed \u00f3 " 1377 // 345.....6789ABCDEF 1378 + " \u00fa ", 1379 1380 /* A.2.3 Portuguese National Language Single Shift Table 1381 012345.....6789.....A.....B.....C.....DE.....F.....012.....3.....45.....6.....7.....8....*/ 1382 " \u00ea \u00e7\u000c\u00d4\u00f4 \u00c1\u00e1 \u03a6\u0393^\u03a9\u03a0\u03a8\u03a3" 1383 // 9.....ABCDEF.....0123456789ABCDEF.0123456789ABCDEF01.....23456789.....ABCDE 1384 + "\u0398 \u00ca {} \\ [~] |\u00c0 \u00cd " 1385 // F.....012345.....6789AB.....C.....DEF01.....2345.....6789.....ABCDEF.....01234 1386 + "\u00d3 \u00da \u00c3\u00d5 \u00c2 \u20ac \u00ed \u00f3 " 1387 // 5.....6789AB.....C.....DEF..... 1388 + "\u00fa \u00e3\u00f5 \u00e2", 1389 1390 /* A.2.4 Bengali National Language Single Shift Table 1391 01.....23.....4.....5.6.....789A.....BCDEF0123.....45.....6789.....A.....BC.....D..... */ 1392 "@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+ -/<=>\u00a1^\u00a1_#*\u09e6\u09e7 \u09e8\u09e9" 1393 // E.....F.....0.....1.....2.....3.....4.....5.....6.....7.....89A.....B.....C..... 1394 + "\u09ea\u09eb\u09ec\u09ed\u09ee\u09ef\u09df\u09e0\u09e1\u09e2{}\u09e3\u09f2\u09f3" 1395 // D.....E.....F.0.....1.....2.....3.....4.....56789ABCDEF0123456789ABCDEF 1396 + "\u09f4\u09f5\\\u09f6\u09f7\u09f8\u09f9\u09fa [~] |ABCDEFGHIJKLMNO" 1397 // 0123456789ABCDEF012345.....6789ABCDEF0123456789ABCDEF 1398 + "PQRSTUVWXYZ \u20ac ", 1399 1400 /* A.2.5 Gujarati National Language Single Shift Table 1401 01.....23.....4.....5.6.....789A.....BCDEF0123.....45.....6789.....A.....BC.....D..... */ 1402 "@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+ -/<=>\u00a1^\u00a1_#*\u0964\u0965 \u0ae6\u0ae7" 1403 // E.....F.....0.....1.....2.....3.....4.....5.....6789ABCDEF.0123456789ABCDEF 1404 + "\u0ae8\u0ae9\u0aea\u0aeb\u0aec\u0aed\u0aee\u0aef {} \\ [~] " 1405 // 0123456789ABCDEF0123456789ABCDEF012345.....6789ABCDEF0123456789ABCDEF 1406 + "|ABCDEFGHIJKLMNOPQRSTUVWXYZ \u20ac ", 1407 1408 /* A.2.6 Hindi National Language Single Shift Table 1409 01.....23.....4.....5.6.....789A.....BCDEF0123.....45.....6789.....A.....BC.....D..... */ 1410 "@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+ -/<=>\u00a1^\u00a1_#*\u0964\u0965 \u0966\u0967" 1411 // E.....F.....0.....1.....2.....3.....4.....5.....6.....7.....89A.....B.....C..... 1412 + "\u0968\u0969\u096a\u096b\u096c\u096d\u096e\u096f\u0951\u0952{}\u0953\u0954\u0958" 1413 // D.....E.....F.0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A..... 1414 + "\u0959\u095a\\\u095b\u095c\u095d\u095e\u095f\u0960\u0961\u0962\u0963\u0970\u0971" 1415 // BCDEF0123456789ABCDEF0123456789ABCDEF012345.....6789ABCDEF0123456789ABCDEF 1416 + " [~] |ABCDEFGHIJKLMNOPQRSTUVWXYZ \u20ac ", 1417 1418 /* A.2.7 Kannada National Language Single Shift Table 1419 01.....23.....4.....5.6.....789A.....BCDEF0123.....45.....6789.....A.....BC.....D..... */ 1420 "@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+ -/<=>\u00a1^\u00a1_#*\u0964\u0965 \u0ce6\u0ce7" 1421 // E.....F.....0.....1.....2.....3.....4.....5.....6.....7.....89A.....BCDEF.01234567 1422 + "\u0ce8\u0ce9\u0cea\u0ceb\u0cec\u0ced\u0cee\u0cef\u0cde\u0cf1{}\u0cf2 \\ " 1423 // 89ABCDEF0123456789ABCDEF0123456789ABCDEF012345.....6789ABCDEF0123456789ABCDEF 1424 + " [~] |ABCDEFGHIJKLMNOPQRSTUVWXYZ \u20ac ", 1425 1426 /* A.2.8 Malayalam National Language Single Shift Table 1427 01.....23.....4.....5.6.....789A.....BCDEF0123.....45.....6789.....A.....BC.....D..... */ 1428 "@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+ -/<=>\u00a1^\u00a1_#*\u0964\u0965 \u0d66\u0d67" 1429 // E.....F.....0.....1.....2.....3.....4.....5.....6.....7.....89A.....B.....C..... 1430 + "\u0d68\u0d69\u0d6a\u0d6b\u0d6c\u0d6d\u0d6e\u0d6f\u0d70\u0d71{}\u0d72\u0d73\u0d74" 1431 // D.....E.....F.0.....1.....2.....3.....4.....56789ABCDEF0123456789ABCDEF0123456789A 1432 + "\u0d75\u0d7a\\\u0d7b\u0d7c\u0d7d\u0d7e\u0d7f [~] |ABCDEFGHIJKLMNOPQRSTUVWXYZ" 1433 // BCDEF012345.....6789ABCDEF0123456789ABCDEF 1434 + " \u20ac ", 1435 1436 /* A.2.9 Oriya National Language Single Shift Table 1437 01.....23.....4.....5.6.....789A.....BCDEF0123.....45.....6789.....A.....BC.....D..... */ 1438 "@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+ -/<=>\u00a1^\u00a1_#*\u0964\u0965 \u0b66\u0b67" 1439 // E.....F.....0.....1.....2.....3.....4.....5.....6.....7.....89A.....B.....C.....DE 1440 + "\u0b68\u0b69\u0b6a\u0b6b\u0b6c\u0b6d\u0b6e\u0b6f\u0b5c\u0b5d{}\u0b5f\u0b70\u0b71 " 1441 // F.0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF012345.....6789ABCDEF0123456789A 1442 + "\\ [~] |ABCDEFGHIJKLMNOPQRSTUVWXYZ \u20ac " 1443 // BCDEF 1444 + " ", 1445 1446 /* A.2.10 Punjabi National Language Single Shift Table 1447 01.....23.....4.....5.6.....789A.....BCDEF0123.....45.....6789.....A.....BC.....D..... */ 1448 "@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+ -/<=>\u00a1^\u00a1_#*\u0964\u0965 \u0a66\u0a67" 1449 // E.....F.....0.....1.....2.....3.....4.....5.....6.....7.....89A.....B.....C..... 1450 + "\u0a68\u0a69\u0a6a\u0a6b\u0a6c\u0a6d\u0a6e\u0a6f\u0a59\u0a5a{}\u0a5b\u0a5c\u0a5e" 1451 // D.....EF.0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF012345.....6789ABCDEF01 1452 + "\u0a75 \\ [~] |ABCDEFGHIJKLMNOPQRSTUVWXYZ \u20ac " 1453 // 23456789ABCDEF 1454 + " ", 1455 1456 /* A.2.11 Tamil National Language Single Shift Table 1457 NOTE: TS 23.038 V9.1.1 shows code 0x24 as \u0bef, corrected to \u0bee (typo) 1458 01.....23.....4.....5.6.....789A.....BCDEF0123.....45.....6789.....A.....BC.....D..... */ 1459 "@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+ -/<=>\u00a1^\u00a1_#*\u0964\u0965 \u0be6\u0be7" 1460 // E.....F.....0.....1.....2.....3.....4.....5.....6.....7.....89A.....B.....C..... 1461 + "\u0be8\u0be9\u0bea\u0beb\u0bec\u0bed\u0bee\u0bef\u0bf3\u0bf4{}\u0bf5\u0bf6\u0bf7" 1462 // D.....E.....F.0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF012345.....6789ABC 1463 + "\u0bf8\u0bfa\\ [~] |ABCDEFGHIJKLMNOPQRSTUVWXYZ \u20ac " 1464 // DEF0123456789ABCDEF 1465 + " ", 1466 1467 /* A.2.12 Telugu National Language Single Shift Table 1468 NOTE: TS 23.038 V9.1.1 shows code 0x22-0x23 as \u06cc\u06cd, corrected to \u0c6c\u0c6d 1469 01.....23.....4.....5.6.....789A.....BCDEF0123.....45.....6789ABC.....D.....E.....F..... */ 1470 "@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+ -/<=>\u00a1^\u00a1_#* \u0c66\u0c67\u0c68\u0c69" 1471 // 0.....1.....2.....3.....4.....5.....6.....7.....89A.....B.....C.....D.....E.....F. 1472 + "\u0c6a\u0c6b\u0c6c\u0c6d\u0c6e\u0c6f\u0c58\u0c59{}\u0c78\u0c79\u0c7a\u0c7b\u0c7c\\" 1473 // 0.....1.....2.....3456789ABCDEF0123456789ABCDEF0123456789ABCDEF012345.....6789ABCD 1474 + "\u0c7d\u0c7e\u0c7f [~] |ABCDEFGHIJKLMNOPQRSTUVWXYZ \u20ac " 1475 // EF0123456789ABCDEF 1476 + " ", 1477 1478 /* A.2.13 Urdu National Language Single Shift Table 1479 01.....23.....4.....5.6.....789A.....BCDEF0123.....45.....6789.....A.....BC.....D..... */ 1480 "@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+ -/<=>\u00a1^\u00a1_#*\u0600\u0601 \u06f0\u06f1" 1481 // E.....F.....0.....1.....2.....3.....4.....5.....6.....7.....89A.....B.....C..... 1482 + "\u06f2\u06f3\u06f4\u06f5\u06f6\u06f7\u06f8\u06f9\u060c\u060d{}\u060e\u060f\u0610" 1483 // D.....E.....F.0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A..... 1484 + "\u0611\u0612\\\u0613\u0614\u061b\u061f\u0640\u0652\u0658\u066b\u066c\u0672\u0673" 1485 // B.....CDEF.....0123456789ABCDEF0123456789ABCDEF012345.....6789ABCDEF0123456789ABCDEF 1486 + "\u06cd[~]\u06d4|ABCDEFGHIJKLMNOPQRSTUVWXYZ \u20ac " 1487 }; 1488 1489 static { 1490 enableCountrySpecificEncodings(); 1491 int numTables = sLanguageTables.length; 1492 int numShiftTables = sLanguageShiftTables.length; 1493 if (numTables != numShiftTables) { 1494 Rlog.e(TAG, "Error: language tables array length " + numTables + 1495 " != shift tables array length " + numShiftTables); 1496 } 1497 1498 sCharsToGsmTables = new SparseIntArray[numTables]; 1499 for (int i = 0; i < numTables; i++) { 1500 String table = sLanguageTables[i]; 1501 1502 int tableLen = table.length(); 1503 if (tableLen != 0 && tableLen != 128) { 1504 Rlog.e(TAG, "Error: language tables index " + i + 1505 " length " + tableLen + " (expected 128 or 0)"); 1506 } 1507 1508 SparseIntArray charToGsmTable = new SparseIntArray(tableLen); 1509 sCharsToGsmTables[i] = charToGsmTable; 1510 for (int j = 0; j < tableLen; j++) { 1511 char c = table.charAt(j); 1512 charToGsmTable.put(c, j); 1513 } 1514 } 1515 1516 sCharsToShiftTables = new SparseIntArray[numTables]; 1517 for (int i = 0; i < numShiftTables; i++) { 1518 String shiftTable = sLanguageShiftTables[i]; 1519 1520 int shiftTableLen = shiftTable.length(); 1521 if (shiftTableLen != 0 && shiftTableLen != 128) { 1522 Rlog.e(TAG, "Error: language shift tables index " + i + 1523 " length " + shiftTableLen + " (expected 128 or 0)"); 1524 } 1525 1526 SparseIntArray charToShiftTable = new SparseIntArray(shiftTableLen); 1527 sCharsToShiftTables[i] = charToShiftTable; 1528 for (int j = 0; j < shiftTableLen; j++) { 1529 char c = shiftTable.charAt(j); 1530 if (c != ' ') { 1531 charToShiftTable.put(c, j); 1532 } 1533 } 1534 } 1535 } 1536 } 1537