OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium 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 "base/json/json_parser.h" | 5 #include "base/json/json_parser.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 CBU8_APPEND_UNSAFE(code_unit8, offset, code_point); | 642 CBU8_APPEND_UNSAFE(code_unit8, offset, code_point); |
643 } else { | 643 } else { |
644 // Not a surrogate. | 644 // Not a surrogate. |
645 DCHECK(CBU16_IS_SINGLE(code_unit16_high)); | 645 DCHECK(CBU16_IS_SINGLE(code_unit16_high)); |
646 if (!IsValidCharacter(code_unit16_high)) | 646 if (!IsValidCharacter(code_unit16_high)) |
647 return false; | 647 return false; |
648 | 648 |
649 CBU8_APPEND_UNSAFE(code_unit8, offset, code_unit16_high); | 649 CBU8_APPEND_UNSAFE(code_unit8, offset, code_unit16_high); |
650 } | 650 } |
651 | 651 |
652 dest_string->append(code_unit8); | 652 dest_string->append(code_unit8, offset); |
653 return true; | 653 return true; |
654 } | 654 } |
655 | 655 |
656 void JSONParser::DecodeUTF8(const int32_t& point, StringBuilder* dest) { | 656 void JSONParser::DecodeUTF8(const int32_t& point, StringBuilder* dest) { |
657 DCHECK(IsValidCharacter(point)); | 657 DCHECK(IsValidCharacter(point)); |
658 | 658 |
659 // Anything outside of the basic ASCII plane will need to be decoded from | 659 // Anything outside of the basic ASCII plane will need to be decoded from |
660 // int32_t to a multi-byte sequence. | 660 // int32_t to a multi-byte sequence. |
661 if (point < kExtendedASCIIStart) { | 661 if (point < kExtendedASCIIStart) { |
662 dest->Append(static_cast<char>(point)); | 662 dest->Append(static_cast<char>(point)); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
830 const std::string& description) { | 830 const std::string& description) { |
831 if (line || column) { | 831 if (line || column) { |
832 return StringPrintf("Line: %i, column: %i, %s", | 832 return StringPrintf("Line: %i, column: %i, %s", |
833 line, column, description.c_str()); | 833 line, column, description.c_str()); |
834 } | 834 } |
835 return description; | 835 return description; |
836 } | 836 } |
837 | 837 |
838 } // namespace internal | 838 } // namespace internal |
839 } // namespace base | 839 } // namespace base |
OLD | NEW |