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

Side by Side Diff: src/debug-agent.cc

Issue 121173009: String:WriteUtf8: Add REPLACE_INVALID_UTF8 option (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: DISALLOW_INVALID_UTF8 flag and fixes Created 6 years, 11 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 if (conn->Send(buffer, len) < len) { 412 if (conn->Send(buffer, len) < len) {
413 return false; 413 return false;
414 } 414 }
415 415
416 // Send message body as UTF-8. 416 // Send message body as UTF-8.
417 int buffer_position = 0; // Current buffer position. 417 int buffer_position = 0; // Current buffer position.
418 previous = unibrow::Utf16::kNoPreviousCharacter; 418 previous = unibrow::Utf16::kNoPreviousCharacter;
419 for (int i = 0; i < message.length(); i++) { 419 for (int i = 0; i < message.length(); i++) {
420 // Write next UTF-8 encoded character to buffer. 420 // Write next UTF-8 encoded character to buffer.
421 uint16_t character = message[i]; 421 uint16_t character = message[i];
422 // @TODO Fix this Utf8::Encode call site somehow.
422 buffer_position += 423 buffer_position +=
423 unibrow::Utf8::Encode(buffer + buffer_position, character, previous); 424 unibrow::Utf8::Encode(buffer + buffer_position, character, previous);
424 ASSERT(buffer_position <= kBufferSize); 425 ASSERT(buffer_position <= kBufferSize);
425 426
426 // Send buffer if full or last character is encoded. 427 // Send buffer if full or last character is encoded.
427 if (kBufferSize - buffer_position < 428 if (kBufferSize - buffer_position <
428 unibrow::Utf16::kMaxExtraUtf8BytesForOneUtf16CodeUnit || 429 unibrow::Utf16::kMaxExtraUtf8BytesForOneUtf16CodeUnit ||
429 i == message.length() - 1) { 430 i == message.length() - 1) {
430 if (unibrow::Utf16::IsLeadSurrogate(character)) { 431 if (unibrow::Utf16::IsLeadSurrogate(character)) {
431 const int kEncodedSurrogateLength = 432 const int kEncodedSurrogateLength =
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 return total_received; 495 return total_received;
495 } 496 }
496 total_received += received; 497 total_received += received;
497 } 498 }
498 return total_received; 499 return total_received;
499 } 500 }
500 501
501 } } // namespace v8::internal 502 } } // namespace v8::internal
502 503
503 #endif // ENABLE_DEBUGGER_SUPPORT 504 #endif // ENABLE_DEBUGGER_SUPPORT
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698