OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 8294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8305 // Convert the UTF-16 string to a UTF-8 buffer. Start at the specified offset. | 8305 // Convert the UTF-16 string to a UTF-8 buffer. Start at the specified offset. |
8306 stream.Reset(this, offset); | 8306 stream.Reset(this, offset); |
8307 character_position = offset; | 8307 character_position = offset; |
8308 int utf8_byte_position = 0; | 8308 int utf8_byte_position = 0; |
8309 last = unibrow::Utf16::kNoPreviousCharacter; | 8309 last = unibrow::Utf16::kNoPreviousCharacter; |
8310 while (stream.HasMore() && character_position++ < offset + length) { | 8310 while (stream.HasMore() && character_position++ < offset + length) { |
8311 uint16_t character = stream.GetNext(); | 8311 uint16_t character = stream.GetNext(); |
8312 if (allow_nulls == DISALLOW_NULLS && character == 0) { | 8312 if (allow_nulls == DISALLOW_NULLS && character == 0) { |
8313 character = ' '; | 8313 character = ' '; |
8314 } | 8314 } |
8315 utf8_byte_position += | 8315 utf8_byte_position += unibrow::Utf8::Encode(result + utf8_byte_position, |
8316 unibrow::Utf8::Encode(result + utf8_byte_position, character, last); | 8316 character, |
| 8317 last, |
| 8318 true); |
8317 last = character; | 8319 last = character; |
8318 } | 8320 } |
8319 result[utf8_byte_position] = 0; | 8321 result[utf8_byte_position] = 0; |
8320 return SmartArrayPointer<char>(result); | 8322 return SmartArrayPointer<char>(result); |
8321 } | 8323 } |
8322 | 8324 |
8323 | 8325 |
8324 SmartArrayPointer<char> String::ToCString(AllowNullsFlag allow_nulls, | 8326 SmartArrayPointer<char> String::ToCString(AllowNullsFlag allow_nulls, |
8325 RobustnessFlag robust_flag, | 8327 RobustnessFlag robust_flag, |
8326 int* length_return) { | 8328 int* length_return) { |
(...skipping 8339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16666 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16668 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16667 static const char* error_messages_[] = { | 16669 static const char* error_messages_[] = { |
16668 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16670 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16669 }; | 16671 }; |
16670 #undef ERROR_MESSAGES_TEXTS | 16672 #undef ERROR_MESSAGES_TEXTS |
16671 return error_messages_[reason]; | 16673 return error_messages_[reason]; |
16672 } | 16674 } |
16673 | 16675 |
16674 | 16676 |
16675 } } // namespace v8::internal | 16677 } } // namespace v8::internal |
OLD | NEW |