Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Side by Side Diff: runtime/vm/unicode.h

Issue 10584044: Check that the C string passed to Dart_NewString is valid UTF-8. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 static const intptr_t kMaxOneByteChar = 0x7F; 17 static const intptr_t kMaxOneByteChar = 0x7F;
18 static const intptr_t kMaxTwoByteChar = 0x7FF; 18 static const intptr_t kMaxTwoByteChar = 0x7FF;
19 static const intptr_t kMaxThreeByteChar = 0xFFFF; 19 static const intptr_t kMaxThreeByteChar = 0xFFFF;
20 static const intptr_t kMaxFourByteChar = 0x10FFFF; 20 static const intptr_t kMaxFourByteChar = 0x10FFFF;
21 21
22 static intptr_t CodePointCount(const char* str, intptr_t* width); 22 static intptr_t CodePointCount(const char* str, intptr_t* width);
23 23
24 static bool IsValid(const char* src);
25
24 static intptr_t Length(int32_t ch); 26 static intptr_t Length(int32_t ch);
25 static intptr_t Length(const String& str); 27 static intptr_t Length(const String& str);
26 28
27 static intptr_t Encode(int32_t ch, char* dst); 29 static intptr_t Encode(int32_t ch, char* dst);
28 static intptr_t Encode(const String& src, char* dst, intptr_t len); 30 static intptr_t Encode(const String& src, char* dst, intptr_t len);
29 31
30 static intptr_t Decode(const char*, int32_t* ch); 32 static intptr_t Decode(const char*, int32_t* ch);
31 static bool Decode(const char* src, uint8_t* dst, intptr_t len); 33 static bool Decode(const char* src, uint8_t* dst, intptr_t len);
32 static bool Decode(const char* src, uint16_t* dst, intptr_t len); 34 static bool Decode(const char* src, uint16_t* dst, intptr_t len);
33 static bool Decode(const char* src, uint32_t* dst, intptr_t len); 35 static bool Decode(const char* src, uint32_t* dst, intptr_t len);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 // Data for small code points with one mapping 95 // Data for small code points with one mapping
94 static const int16_t stage2_[]; 96 static const int16_t stage2_[];
95 97
96 // Data for large code points or code points with both mappings. 98 // Data for large code points or code points with both mappings.
97 static const int32_t stage2_exception_[][2]; 99 static const int32_t stage2_exception_[][2];
98 }; 100 };
99 101
100 } // namespace dart 102 } // namespace dart
101 103
102 #endif // VM_UNICODE_H_ 104 #endif // VM_UNICODE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698