OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/inspector/string-16.h" | 5 #include "src/inspector/string-16.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cctype> | 8 #include <cctype> |
9 #include <cstdlib> | 9 #include <cstdlib> |
10 #include <cstring> | 10 #include <cstring> |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 const size_t kBufferSize = 50; | 370 const size_t kBufferSize = 50; |
371 char buffer[kBufferSize]; | 371 char buffer[kBufferSize]; |
372 v8::base::OS::SNPrintF(buffer, kBufferSize, "%d", number); | 372 v8::base::OS::SNPrintF(buffer, kBufferSize, "%d", number); |
373 return String16(buffer); | 373 return String16(buffer); |
374 } | 374 } |
375 | 375 |
376 // static | 376 // static |
377 String16 String16::fromInteger(size_t number) { | 377 String16 String16::fromInteger(size_t number) { |
378 const size_t kBufferSize = 50; | 378 const size_t kBufferSize = 50; |
379 char buffer[kBufferSize]; | 379 char buffer[kBufferSize]; |
| 380 #if !defined(_WIN32) && !defined(_WIN64) |
380 v8::base::OS::SNPrintF(buffer, kBufferSize, "%zu", number); | 381 v8::base::OS::SNPrintF(buffer, kBufferSize, "%zu", number); |
| 382 #else |
| 383 v8::base::OS::SNPrintF(buffer, kBufferSize, "%Iu", number); |
| 384 #endif |
381 return String16(buffer); | 385 return String16(buffer); |
382 } | 386 } |
383 | 387 |
384 // static | 388 // static |
385 String16 String16::fromDouble(double number) { | 389 String16 String16::fromDouble(double number) { |
386 std::ostringstream s; | 390 std::ostringstream s; |
387 s.imbue(std::locale("C")); | 391 s.imbue(std::locale("C")); |
388 s << std::fixed << std::setprecision(std::numeric_limits<double>::digits10) | 392 s << std::fixed << std::setprecision(std::numeric_limits<double>::digits10) |
389 << number; | 393 << number; |
390 return String16(s.str().c_str()); | 394 return String16(s.str().c_str()); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 // There should be room left, since one UChar hasn't been | 513 // There should be room left, since one UChar hasn't been |
510 // converted. | 514 // converted. |
511 DCHECK((buffer + 3) <= (buffer + bufferVector.size())); | 515 DCHECK((buffer + 3) <= (buffer + bufferVector.size())); |
512 putUTF8Triple(buffer, *characters); | 516 putUTF8Triple(buffer, *characters); |
513 } | 517 } |
514 | 518 |
515 return std::string(bufferVector.data(), buffer - bufferVector.data()); | 519 return std::string(bufferVector.data(), buffer - bufferVector.data()); |
516 } | 520 } |
517 | 521 |
518 } // namespace v8_inspector | 522 } // namespace v8_inspector |
OLD | NEW |