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

Unified Diff: vm/unicode.cc

Issue 11419259: Fix bug in Utf8::CodePointCount which was causing some strings with latin1 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « vm/unicode.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vm/unicode.cc
===================================================================
--- vm/unicode.cc (revision 15591)
+++ vm/unicode.cc (working copy)
@@ -53,23 +53,25 @@
};
-// Returns a count of the number of UTF-8 trail bytes.
-intptr_t Utf8::CodePointCount(const uint8_t* utf8_array,
- intptr_t array_len,
- Type* type) {
+// Returns the most restricted coding form in which the sequence of utf8
+// characters in 'utf8_array' can be represented in, and the number of
+// code units needed in that form.
+intptr_t Utf8::CodeUnitCount(const uint8_t* utf8_array,
+ intptr_t array_len,
+ Type* type) {
intptr_t len = 0;
Type char_type = kLatin1;
for (intptr_t i = 0; i < array_len; i++) {
uint8_t code_unit = utf8_array[i];
if (!IsTrailByte(code_unit)) {
++len;
- }
- if (!IsLatin1SequenceStart(code_unit)) { // > U+00FF
- if (IsSupplementarySequenceStart(code_unit)) { // >= U+10000
- char_type = kSupplementary;
- ++len;
- } else if (char_type == kLatin1) {
- char_type = kBMP;
+ if (!IsLatin1SequenceStart(code_unit)) { // > U+00FF
+ if (IsSupplementarySequenceStart(code_unit)) { // >= U+10000
+ char_type = kSupplementary;
+ ++len;
+ } else if (char_type == kLatin1) {
+ char_type = kBMP;
+ }
}
}
}
« no previous file with comments | « vm/unicode.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698