OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 #ifndef WTF_UTF8_h | 26 #ifndef WTF_UTF8_h |
27 #define WTF_UTF8_h | 27 #define WTF_UTF8_h |
28 | 28 |
29 #include "wtf/WTFExport.h" | 29 #include "wtf/WTFExport.h" |
30 #include "wtf/text/Unicode.h" | 30 #include "wtf/text/Unicode.h" |
31 | 31 |
32 namespace WTF { | 32 namespace WTF { |
33 namespace Unicode { | 33 namespace Unicode { |
34 | 34 |
35 typedef enum { | 35 typedef enum { |
36 conversionOK, // conversion successful | 36 conversionOK, // conversion successful |
37 sourceExhausted, // partial character in source, but hit end | 37 sourceExhausted, // partial character in source, but hit end |
38 targetExhausted, // insuff. room in target for conversion | 38 targetExhausted, // insuff. room in target for conversion |
39 sourceIllegal // source sequence is illegal/malformed | 39 sourceIllegal // source sequence is illegal/malformed |
40 } ConversionResult; | 40 } ConversionResult; |
41 | 41 |
42 // These conversion functions take a "strict" argument. When this | 42 // These conversion functions take a "strict" argument. When this flag is set to |
43 // flag is set to strict, both irregular sequences and isolated surrogates | 43 // strict, both irregular sequences and isolated surrogates will cause an error. |
44 // will cause an error. When the flag is set to lenient, both irregular | 44 // When the flag is set to lenient, both irregular sequences and isolated |
45 // sequences and isolated surrogates are converted. | 45 // surrogates are converted. |
46 // | 46 // |
47 // Whether the flag is strict or lenient, all illegal sequences will cause | 47 // Whether the flag is strict or lenient, all illegal sequences will cause an |
48 // an error return. This includes sequences such as: <F4 90 80 80>, <C0 80>, | 48 // error return. This includes sequences such as: <F4 90 80 80>, <C0 80>, or |
49 // or <A0> in UTF-8, and values above 0x10FFFF in UTF-32. Conformant code | 49 // <A0> in UTF-8, and values above 0x10FFFF in UTF-32. Conformant code must |
50 // must check for illegal sequences. | 50 // check for illegal sequences. |
51 // | 51 // |
52 // When the flag is set to lenient, characters over 0x10FFFF are converted | 52 // When the flag is set to lenient, characters over 0x10FFFF are converted to |
53 // to the replacement character; otherwise (when the flag is set to strict) | 53 // the replacement character; otherwise (when the flag is set to strict) they |
54 // they constitute an error. | 54 // constitute an error. |
55 | 55 |
56 WTF_EXPORT ConversionResult convertUTF8ToUTF16( | 56 WTF_EXPORT ConversionResult convertUTF8ToUTF16( |
57 const char** sourceStart, const char* sourceEnd, | 57 const char** sourceStart, const char* sourceEnd, |
58 UChar** targetStart, UChar* targetEnd, bool* isSourceAllASCI
I = 0, bool strict = true); | 58 UChar** targetStart, UChar* targetEnd, bool* isSourceAllASCII = 0, bool stri
ct = true); |
59 | 59 |
60 WTF_EXPORT ConversionResult convertLatin1ToUTF8( | 60 WTF_EXPORT ConversionResult convertLatin1ToUTF8( |
61 const LChar** sourceStart, const LChar* sourceEnd, | 61 const LChar** sourceStart, const LChar* sourceEnd, |
62 char** targetStart, char* targetEnd); | 62 char** targetStart, char* targetEnd); |
63 | 63 |
64 WTF_EXPORT ConversionResult convertUTF16ToUTF8( | 64 WTF_EXPORT ConversionResult convertUTF16ToUTF8( |
65 const UChar** sourceStart, const UChar* sourceEnd, | 65 const UChar** sourceStart, const UChar* sourceEnd, |
66 char** targetStart, char* targetEnd, bool strict = true); | 66 char** targetStart, char* targetEnd, bool strict = true); |
67 | 67 |
68 WTF_EXPORT unsigned calculateStringHashAndLengthFromUTF8MaskingTop8Bits(cons
t char* data, const char* dataEnd, unsigned& dataLength, unsigned& utf16Length); | 68 WTF_EXPORT unsigned calculateStringHashAndLengthFromUTF8MaskingTop8Bits(const ch
ar* data, const char* dataEnd, unsigned& dataLength, unsigned& utf16Length); |
69 | 69 |
70 WTF_EXPORT bool equalUTF16WithUTF8(const UChar* a, const UChar* aEnd, const
char* b, const char* bEnd); | 70 WTF_EXPORT bool equalUTF16WithUTF8(const UChar* a, const UChar* aEnd, const char
* b, const char* bEnd); |
71 WTF_EXPORT bool equalLatin1WithUTF8(const LChar* a, const LChar* aEnd, const
char* b, const char* bEnd); | 71 WTF_EXPORT bool equalLatin1WithUTF8(const LChar* a, const LChar* aEnd, const cha
r* b, const char* bEnd); |
72 | 72 |
73 } // namespace Unicode | 73 } // namespace Unicode |
74 } // namespace WTF | 74 } // namespace WTF |
75 | 75 |
76 #endif // WTF_UTF8_h | 76 #endif // WTF_UTF8_h |
OLD | NEW |