< prev index next >

src/hotspot/share/utilities/utf8.cpp

Print this page
rev 58452 : imported patch pkg_name_from_class


 289           case 't': if (buffer != NULL) buffer[length] = '\t'; ptr += 2; length++; break;
 290           case 'n': if (buffer != NULL) buffer[length] = '\n'; ptr += 2; length++; break;
 291           case 'r': if (buffer != NULL) buffer[length] = '\r'; ptr += 2; length++; break;
 292           case 'f': if (buffer != NULL) buffer[length] = '\f'; ptr += 2; length++; break;
 293           default:
 294             ShouldNotReachHere();
 295         }
 296       }
 297     }
 298     if (round == 0) {
 299       buffer = NEW_RESOURCE_ARRAY(char, length + 1);
 300       ptr = quoted_ascii_str;
 301     } else {
 302       buffer[length] = '\0';
 303     }
 304   }
 305   return buffer;
 306 }
 307 #endif // !PRODUCT
 308 
 309 // Returns NULL if 'c' it not found. This only works as long
 310 // as 'c' is an ASCII character
 311 const jbyte* UTF8::strrchr(const jbyte* base, int length, jbyte c) {
 312   assert(length >= 0, "sanity check");
 313   assert(c >= 0, "does not work for non-ASCII characters");
 314   // Skip backwards in string until 'c' is found or end is reached
 315   while(--length >= 0 && base[length] != c);
 316   return (length < 0) ? NULL : &base[length];
 317 }
 318 
 319 bool UTF8::equal(const jbyte* base1, int length1, const jbyte* base2, int length2) {
 320   // Length must be the same
 321   if (length1 != length2) return false;
 322   for (int i = 0; i < length1; i++) {
 323     if (base1[i] != base2[i]) return false;
 324   }
 325   return true;
 326 }
 327 
 328 bool UTF8::is_supplementary_character(const unsigned char* str) {
 329   return ((str[0] & 0xFF) == 0xED) && ((str[1] & 0xF0) == 0xA0) && ((str[2] & 0xC0) == 0x80)
 330       && ((str[3] & 0xFF) == 0xED) && ((str[4] & 0xF0) == 0xB0) && ((str[5] & 0xC0) == 0x80);
 331 }
 332 
 333 jint UTF8::get_supplementary_character(const unsigned char* str) {
 334   return 0x10000 + ((str[1] & 0x0f) << 16) + ((str[2] & 0x3f) << 10)
 335                  + ((str[4] & 0x0f) << 6)  + (str[5] & 0x3f);
 336 }
 337 
 338 bool UTF8::is_legal_utf8(const unsigned char* buffer, int length,




 289           case 't': if (buffer != NULL) buffer[length] = '\t'; ptr += 2; length++; break;
 290           case 'n': if (buffer != NULL) buffer[length] = '\n'; ptr += 2; length++; break;
 291           case 'r': if (buffer != NULL) buffer[length] = '\r'; ptr += 2; length++; break;
 292           case 'f': if (buffer != NULL) buffer[length] = '\f'; ptr += 2; length++; break;
 293           default:
 294             ShouldNotReachHere();
 295         }
 296       }
 297     }
 298     if (round == 0) {
 299       buffer = NEW_RESOURCE_ARRAY(char, length + 1);
 300       ptr = quoted_ascii_str;
 301     } else {
 302       buffer[length] = '\0';
 303     }
 304   }
 305   return buffer;
 306 }
 307 #endif // !PRODUCT
 308 










 309 bool UTF8::equal(const jbyte* base1, int length1, const jbyte* base2, int length2) {
 310   // Length must be the same
 311   if (length1 != length2) return false;
 312   for (int i = 0; i < length1; i++) {
 313     if (base1[i] != base2[i]) return false;
 314   }
 315   return true;
 316 }
 317 
 318 bool UTF8::is_supplementary_character(const unsigned char* str) {
 319   return ((str[0] & 0xFF) == 0xED) && ((str[1] & 0xF0) == 0xA0) && ((str[2] & 0xC0) == 0x80)
 320       && ((str[3] & 0xFF) == 0xED) && ((str[4] & 0xF0) == 0xB0) && ((str[5] & 0xC0) == 0x80);
 321 }
 322 
 323 jint UTF8::get_supplementary_character(const unsigned char* str) {
 324   return 0x10000 + ((str[1] & 0x0f) << 16) + ((str[2] & 0x3f) << 10)
 325                  + ((str[4] & 0x0f) << 6)  + (str[5] & 0x3f);
 326 }
 327 
 328 bool UTF8::is_legal_utf8(const unsigned char* buffer, int length,


< prev index next >