| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> | 3 * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 bool equalUTF16WithUTF8(const UChar* a, const UChar* aEnd, const char* b, const
char* bEnd) | 435 bool equalUTF16WithUTF8(const UChar* a, const UChar* aEnd, const char* b, const
char* bEnd) |
| 436 { | 436 { |
| 437 return equalWithUTF8Internal(a, aEnd, b, bEnd); | 437 return equalWithUTF8Internal(a, aEnd, b, bEnd); |
| 438 } | 438 } |
| 439 | 439 |
| 440 bool equalLatin1WithUTF8(const LChar* a, const LChar* aEnd, const char* b, const
char* bEnd) | 440 bool equalLatin1WithUTF8(const LChar* a, const LChar* aEnd, const char* b, const
char* bEnd) |
| 441 { | 441 { |
| 442 return equalWithUTF8Internal(a, aEnd, b, bEnd); | 442 return equalWithUTF8Internal(a, aEnd, b, bEnd); |
| 443 } | 443 } |
| 444 | 444 |
| 445 bool isUTF8andNotASCII(const char* data, size_t length) | |
| 446 { | |
| 447 // This cast is necessary because U8_NEXT uses int32_ts. | |
| 448 int32_t srcLen = static_cast<int32_t>(length); | |
| 449 int32_t charIndex = 0; | |
| 450 bool isASCIIOnly = true; | |
| 451 | |
| 452 while (charIndex < srcLen) { | |
| 453 int32_t codePoint; | |
| 454 if (static_cast<uint8_t>(data[charIndex]) >= 0x80) | |
| 455 isASCIIOnly = false; | |
| 456 U8_NEXT(data, charIndex, srcLen, codePoint); | |
| 457 if (!U_IS_UNICODE_CHAR(codePoint)) | |
| 458 return false; | |
| 459 } | |
| 460 return !isASCIIOnly; | |
| 461 } | |
| 462 | |
| 463 } // namespace Unicode | 445 } // namespace Unicode |
| 464 } // namespace WTF | 446 } // namespace WTF |
| OLD | NEW |