OLD | NEW |
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 Loading... |
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 buffer_position += | 422 buffer_position += unibrow::Utf8::Encode(buffer + buffer_position, |
423 unibrow::Utf8::Encode(buffer + buffer_position, character, previous); | 423 character, |
| 424 previous, |
| 425 true); |
424 ASSERT(buffer_position <= kBufferSize); | 426 ASSERT(buffer_position <= kBufferSize); |
425 | 427 |
426 // Send buffer if full or last character is encoded. | 428 // Send buffer if full or last character is encoded. |
427 if (kBufferSize - buffer_position < | 429 if (kBufferSize - buffer_position < |
428 unibrow::Utf16::kMaxExtraUtf8BytesForOneUtf16CodeUnit || | 430 unibrow::Utf16::kMaxExtraUtf8BytesForOneUtf16CodeUnit || |
429 i == message.length() - 1) { | 431 i == message.length() - 1) { |
430 if (unibrow::Utf16::IsLeadSurrogate(character)) { | 432 if (unibrow::Utf16::IsLeadSurrogate(character)) { |
431 const int kEncodedSurrogateLength = | 433 const int kEncodedSurrogateLength = |
432 unibrow::Utf16::kUtf8BytesToCodeASurrogate; | 434 unibrow::Utf16::kUtf8BytesToCodeASurrogate; |
433 ASSERT(buffer_position >= kEncodedSurrogateLength); | 435 ASSERT(buffer_position >= kEncodedSurrogateLength); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 return total_received; | 496 return total_received; |
495 } | 497 } |
496 total_received += received; | 498 total_received += received; |
497 } | 499 } |
498 return total_received; | 500 return total_received; |
499 } | 501 } |
500 | 502 |
501 } } // namespace v8::internal | 503 } } // namespace v8::internal |
502 | 504 |
503 #endif // ENABLE_DEBUGGER_SUPPORT | 505 #endif // ENABLE_DEBUGGER_SUPPORT |
OLD | NEW |