OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 static const unsigned kMaxEncodedSize = 4; | 163 static const unsigned kMaxEncodedSize = 4; |
164 static const unsigned kMaxOneByteChar = 0x7f; | 164 static const unsigned kMaxOneByteChar = 0x7f; |
165 static const unsigned kMaxTwoByteChar = 0x7ff; | 165 static const unsigned kMaxTwoByteChar = 0x7ff; |
166 static const unsigned kMaxThreeByteChar = 0xffff; | 166 static const unsigned kMaxThreeByteChar = 0xffff; |
167 static const unsigned kMaxFourByteChar = 0x1fffff; | 167 static const unsigned kMaxFourByteChar = 0x1fffff; |
168 | 168 |
169 // A single surrogate is coded as a 3 byte UTF-8 sequence, but two together | 169 // A single surrogate is coded as a 3 byte UTF-8 sequence, but two together |
170 // that match are coded as a 4 byte UTF-8 sequence. | 170 // that match are coded as a 4 byte UTF-8 sequence. |
171 static const unsigned kBytesSavedByCombiningSurrogates = 2; | 171 static const unsigned kBytesSavedByCombiningSurrogates = 2; |
172 static const unsigned kSizeOfUnmatchedSurrogate = 3; | 172 static const unsigned kSizeOfUnmatchedSurrogate = 3; |
173 | |
174 private: | |
175 template <unsigned s> friend class Utf8InputBuffer; | |
176 friend class Test; | |
177 static inline uchar ValueOf(const byte* str, | 173 static inline uchar ValueOf(const byte* str, |
178 unsigned length, | 174 unsigned length, |
179 unsigned* cursor); | 175 unsigned* cursor); |
180 }; | 176 }; |
181 | 177 |
182 // --- C h a r a c t e r S t r e a m --- | 178 // --- C h a r a c t e r S t r e a m --- |
183 | 179 |
184 class CharacterStream { | 180 class CharacterStream { |
185 public: | 181 public: |
186 inline uchar GetNext(); | 182 inline uchar GetNext(); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 static const int kMaxWidth = 1; | 314 static const int kMaxWidth = 1; |
319 static int Convert(uchar c, | 315 static int Convert(uchar c, |
320 uchar n, | 316 uchar n, |
321 uchar* result, | 317 uchar* result, |
322 bool* allow_caching_ptr); | 318 bool* allow_caching_ptr); |
323 }; | 319 }; |
324 | 320 |
325 } // namespace unibrow | 321 } // namespace unibrow |
326 | 322 |
327 #endif // V8_UNICODE_H_ | 323 #endif // V8_UNICODE_H_ |
OLD | NEW |