| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VM_UNICODE_H_ | 5 #ifndef VM_UNICODE_H_ |
| 6 #define VM_UNICODE_H_ | 6 #define VM_UNICODE_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
| 10 | 10 |
| 11 namespace dart { | 11 namespace dart { |
| 12 | 12 |
| 13 class String; | 13 class String; |
| 14 | 14 |
| 15 class Utf8 : AllStatic { | 15 class Utf8 : AllStatic { |
| 16 public: | 16 public: |
| 17 enum Type { | 17 enum Type { |
| 18 kAscii = 0, // ASCII character set. | 18 kLatin1 = 0, // Latin-1 character set. |
| 19 kBMP, // Basic Multilingual Plane. | 19 kBMP, // Basic Multilingual Plane. |
| 20 kSMP, // Supplementary Multilingual Plane. | 20 kSMP, // Supplementary Multilingual Plane. |
| 21 }; | 21 }; |
| 22 | 22 |
| 23 static const intptr_t kMaxOneByteChar = 0x7F; | 23 static const intptr_t kMaxOneByteChar = 0x7F; |
| 24 static const intptr_t kMaxTwoByteChar = 0x7FF; | 24 static const intptr_t kMaxTwoByteChar = 0x7FF; |
| 25 static const intptr_t kMaxThreeByteChar = 0xFFFF; | 25 static const intptr_t kMaxThreeByteChar = 0xFFFF; |
| 26 static const intptr_t kMaxFourByteChar = 0x10FFFF; | 26 static const intptr_t kMaxFourByteChar = 0x10FFFF; |
| 27 static const intptr_t kMaxBmpCodepoint = 0xffff; | 27 static const intptr_t kMaxBmpCodepoint = 0xffff; |
| 28 static const int32_t kLeadOffset = (0xD800 - (0x10000 >> 10)); | 28 static const int32_t kLeadOffset = (0xD800 - (0x10000 >> 10)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 39 static intptr_t Length(int32_t ch); | 39 static intptr_t Length(int32_t ch); |
| 40 static intptr_t Length(const String& str); | 40 static intptr_t Length(const String& str); |
| 41 | 41 |
| 42 static intptr_t Encode(int32_t ch, char* dst); | 42 static intptr_t Encode(int32_t ch, char* dst); |
| 43 static intptr_t Encode(const String& src, char* dst, intptr_t len); | 43 static intptr_t Encode(const String& src, char* dst, intptr_t len); |
| 44 | 44 |
| 45 static intptr_t Decode(const uint8_t* utf8_array, | 45 static intptr_t Decode(const uint8_t* utf8_array, |
| 46 intptr_t array_len, | 46 intptr_t array_len, |
| 47 int32_t* ch); | 47 int32_t* ch); |
| 48 | 48 |
| 49 static bool DecodeToAscii(const uint8_t* utf8_array, | 49 static bool DecodeToLatin1(const uint8_t* utf8_array, |
| 50 intptr_t array_len, | 50 intptr_t array_len, |
| 51 uint8_t* dst, | 51 uint8_t* dst, |
| 52 intptr_t len); | 52 intptr_t len); |
| 53 static bool DecodeToUTF16(const uint8_t* utf8_array, | 53 static bool DecodeToUTF16(const uint8_t* utf8_array, |
| 54 intptr_t array_len, | 54 intptr_t array_len, |
| 55 uint16_t* dst, | 55 uint16_t* dst, |
| 56 intptr_t len); | 56 intptr_t len); |
| 57 static bool DecodeToUTF32(const uint8_t* utf8_array, | 57 static bool DecodeToUTF32(const uint8_t* utf8_array, |
| 58 intptr_t array_len, | 58 intptr_t array_len, |
| 59 uint32_t* dst, | 59 uint32_t* dst, |
| 60 intptr_t len); | 60 intptr_t len); |
| 61 static bool DecodeCStringToUTF32(const char* str, | 61 static bool DecodeCStringToUTF32(const char* str, |
| 62 uint32_t* dst, | 62 uint32_t* dst, |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 // Data for small code points with one mapping | 128 // Data for small code points with one mapping |
| 129 static const int16_t stage2_[]; | 129 static const int16_t stage2_[]; |
| 130 | 130 |
| 131 // Data for large code points or code points with both mappings. | 131 // Data for large code points or code points with both mappings. |
| 132 static const int32_t stage2_exception_[][2]; | 132 static const int32_t stage2_exception_[][2]; |
| 133 }; | 133 }; |
| 134 | 134 |
| 135 } // namespace dart | 135 } // namespace dart |
| 136 | 136 |
| 137 #endif // VM_UNICODE_H_ | 137 #endif // VM_UNICODE_H_ |
| OLD | NEW |