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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 // The illegality stems from the surrogate not being part of a pair. | 126 // The illegality stems from the surrogate not being part of a pair. |
127 static const int kUtf8BytesToCodeASurrogate = 3; | 127 static const int kUtf8BytesToCodeASurrogate = 3; |
128 static inline uint16_t LeadSurrogate(uint32_t char_code) { | 128 static inline uint16_t LeadSurrogate(uint32_t char_code) { |
129 return 0xd800 + (((char_code - 0x10000) >> 10) & 0x3ff); | 129 return 0xd800 + (((char_code - 0x10000) >> 10) & 0x3ff); |
130 } | 130 } |
131 static inline uint16_t TrailSurrogate(uint32_t char_code) { | 131 static inline uint16_t TrailSurrogate(uint32_t char_code) { |
132 return 0xdc00 + (char_code & 0x3ff); | 132 return 0xdc00 + (char_code & 0x3ff); |
133 } | 133 } |
134 }; | 134 }; |
135 | 135 |
| 136 class Latin1 { |
| 137 public: |
| 138 #ifndef ENABLE_LATIN_1 |
| 139 static const unsigned kMaxChar = 0x7f; |
| 140 #else |
| 141 static const unsigned kMaxChar = 0xff; |
| 142 #endif |
| 143 }; |
136 | 144 |
137 class Utf8 { | 145 class Utf8 { |
138 public: | 146 public: |
139 static inline uchar Length(uchar chr, int previous); | 147 static inline uchar Length(uchar chr, int previous); |
140 static inline unsigned Encode( | 148 static inline unsigned Encode( |
141 char* out, uchar c, int previous); | 149 char* out, uchar c, int previous); |
142 static uchar CalculateValue(const byte* str, | 150 static uchar CalculateValue(const byte* str, |
143 unsigned length, | 151 unsigned length, |
144 unsigned* cursor); | 152 unsigned* cursor); |
145 static const uchar kBadChar = 0xFFFD; | 153 static const uchar kBadChar = 0xFFFD; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 static const int kMaxWidth = 1; | 264 static const int kMaxWidth = 1; |
257 static int Convert(uchar c, | 265 static int Convert(uchar c, |
258 uchar n, | 266 uchar n, |
259 uchar* result, | 267 uchar* result, |
260 bool* allow_caching_ptr); | 268 bool* allow_caching_ptr); |
261 }; | 269 }; |
262 | 270 |
263 } // namespace unibrow | 271 } // namespace unibrow |
264 | 272 |
265 #endif // V8_UNICODE_H_ | 273 #endif // V8_UNICODE_H_ |
OLD | NEW |