1 7 package com.ibm.icu.impl; 8 9 15 16 public final class UCharacterUtility 17 { 18 20 25 public static boolean isNonCharacter(int ch) 26 { 27 if ((ch & NON_CHARACTER_SUFFIX_MIN_3_0_) == 28 NON_CHARACTER_SUFFIX_MIN_3_0_) { 29 return true; 30 } 31 32 return ch >= NON_CHARACTER_MIN_3_1_ && ch <= NON_CHARACTER_MAX_3_1_; 33 } 34 35 37 43 static int toInt(char msc, char lsc) 44 { 45 return ((msc << 16) | lsc); 46 } 47 48 59 static int getNullTermByteSubString(StringBuffer str, byte[] array, 60 int index) 61 { 62 byte b = 1; 63 64 while (b != 0) 65 { 66 b = array[index]; 67 if (b != 0) { 68 str.append((char)(b & 0x00FF)); 69 } 70 index ++; 71 } 72 return index; 73 } 74 75 87 static int compareNullTermByteSubString(String str, byte[] array, 88 int strindex, int aindex) 89 { 90 byte b = 1; 91 int length = str.length(); 92 93 while (b != 0) 94 { 95 b = array[aindex]; 96 aindex ++; 97 if (b == 0) { 98 break; 99 } 100 if (strindex == length 103 || (str.charAt(strindex) != (char)(b & 0xFF))) { 104 return -1; 105 } 106 strindex ++; 107 } 108 return strindex; 109 } 110 111 121 static int skipNullTermByteSubString(byte[] array, int index, 122 int skipcount) 123 { 124 byte b; 125 for (int i = 0; i < skipcount; i ++) 126 { 127 b = 1; 128 while (b != 0) 129 { 130 b = array[index]; 131 index ++; 132 } 133 } 134 return index; 135 } 136 137 148 static int skipByteSubString(byte[] array, int index, int length, 149 byte skipend) 150 { 151 int result; 152 byte b; 153 154 for (result = 0; result < length; result ++) 155 { 156 b = array[index + result]; 157 if (b == skipend) 158 { 159 result ++; 160 break; 161 } 162 } 163 164 return result; 165 } 166 167 169 173 private static final int NON_CHARACTER_SUFFIX_MIN_3_0_ = 0xFFFE; 174 177 private static final int NON_CHARACTER_MIN_3_1_ = 0xFDD0; 178 181 private static final int NON_CHARACTER_MAX_3_1_ = 0xFDEF; 182 183 185 189 private UCharacterUtility() 190 { 191 } 192 } 194 195 | Popular Tags |