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

Side by Side Diff: net/cert/x509_cert_types_mac.cc

Issue 112963005: Update uses of UTF conversions in courgette/, device/, extensions/, google_apis/, gpu/, ipc/, media… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 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 | Annotate | Revision Log
« no previous file with comments | « net/cert/nss_cert_database_unittest.cc ('k') | net/cert/x509_cert_types_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "net/cert/x509_cert_types.h" 5 #include "net/cert/x509_cert_types.h"
6 6
7 #include <CoreServices/CoreServices.h> 7 #include <CoreServices/CoreServices.h>
8 #include <Security/SecAsn1Coder.h> 8 #include <Security/SecAsn1Coder.h>
9 #include <Security/Security.h> 9 #include <Security/Security.h>
10 10
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 reinterpret_cast<std::string::value_type*>(data.Data), 109 reinterpret_cast<std::string::value_type*>(data.Data),
110 data.Length); 110 data.Length);
111 } 111 }
112 112
113 // Converts raw CSSM_DATA in ISO-8859-1 to a std::string in UTF-8. 113 // Converts raw CSSM_DATA in ISO-8859-1 to a std::string in UTF-8.
114 std::string Latin1DataToUTF8String(CSSM_DATA data) { 114 std::string Latin1DataToUTF8String(CSSM_DATA data) {
115 base::string16 utf16; 115 base::string16 utf16;
116 if (!CodepageToUTF16(DataToString(data), base::kCodepageLatin1, 116 if (!CodepageToUTF16(DataToString(data), base::kCodepageLatin1,
117 base::OnStringConversionError::FAIL, &utf16)) 117 base::OnStringConversionError::FAIL, &utf16))
118 return ""; 118 return "";
119 return UTF16ToUTF8(utf16); 119 return base::UTF16ToUTF8(utf16);
120 } 120 }
121 121
122 // Converts big-endian UTF-16 to UTF-8 in a std::string. 122 // Converts big-endian UTF-16 to UTF-8 in a std::string.
123 // Note: The byte-order flipping is done in place on the input buffer! 123 // Note: The byte-order flipping is done in place on the input buffer!
124 bool UTF16BigEndianToUTF8(base::char16* chars, size_t length, 124 bool UTF16BigEndianToUTF8(base::char16* chars, size_t length,
125 std::string* out_string) { 125 std::string* out_string) {
126 for (size_t i = 0; i < length; i++) 126 for (size_t i = 0; i < length; i++)
127 chars[i] = EndianU16_BtoN(chars[i]); 127 chars[i] = EndianU16_BtoN(chars[i]);
128 return UTF16ToUTF8(chars, length, out_string); 128 return base::UTF16ToUTF8(chars, length, out_string);
129 } 129 }
130 130
131 // Converts big-endian UTF-32 to UTF-8 in a std::string. 131 // Converts big-endian UTF-32 to UTF-8 in a std::string.
132 // Note: The byte-order flipping is done in place on the input buffer! 132 // Note: The byte-order flipping is done in place on the input buffer!
133 bool UTF32BigEndianToUTF8(char32* chars, size_t length, 133 bool UTF32BigEndianToUTF8(char32* chars, size_t length,
134 std::string* out_string) { 134 std::string* out_string) {
135 for (size_t i = 0; i < length; ++i) 135 for (size_t i = 0; i < length; ++i)
136 chars[i] = EndianS32_BtoN(chars[i]); 136 chars[i] = EndianS32_BtoN(chars[i]);
137 #if defined(WCHAR_T_IS_UTF32) 137 #if defined(WCHAR_T_IS_UTF32)
138 return WideToUTF8(reinterpret_cast<const wchar_t*>(chars), 138 return base::WideToUTF8(reinterpret_cast<const wchar_t*>(chars),
139 length, out_string); 139 length, out_string);
140 #else 140 #else
141 #error This code doesn't handle 16-bit wchar_t. 141 #error This code doesn't handle 16-bit wchar_t.
142 #endif 142 #endif
143 } 143 }
144 144
145 // Adds a type+value pair to the appropriate vector from a C array. 145 // Adds a type+value pair to the appropriate vector from a C array.
146 // The array is keyed by the matching OIDs from kOIDS[]. 146 // The array is keyed by the matching OIDs from kOIDS[].
147 void AddTypeValuePair(const CSSM_OID type, 147 void AddTypeValuePair(const CSSM_OID type,
148 const std::string& value, 148 const std::string& value,
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 match(locality_name, against.locality_name) && 282 match(locality_name, against.locality_name) &&
283 match(state_or_province_name, against.state_or_province_name) && 283 match(state_or_province_name, against.state_or_province_name) &&
284 match(country_name, against.country_name) && 284 match(country_name, against.country_name) &&
285 match(street_addresses, against.street_addresses) && 285 match(street_addresses, against.street_addresses) &&
286 match(organization_names, against.organization_names) && 286 match(organization_names, against.organization_names) &&
287 match(organization_unit_names, against.organization_unit_names) && 287 match(organization_unit_names, against.organization_unit_names) &&
288 match(domain_components, against.domain_components); 288 match(domain_components, against.domain_components);
289 } 289 }
290 290
291 } // namespace net 291 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/nss_cert_database_unittest.cc ('k') | net/cert/x509_cert_types_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698