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

Side by Side Diff: third_party/WebKit/Source/wtf/text/TextCodecLatin1.cpp

Issue 2473093003: Fix up naming in CString. (Closed)
Patch Set: Created 4 years, 1 month 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 /* 1 /*
2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 237
238 return CString(bytes, resultLength); 238 return CString(bytes, resultLength);
239 } 239 }
240 240
241 template <typename CharType> 241 template <typename CharType>
242 CString TextCodecLatin1::encodeCommon(const CharType* characters, 242 CString TextCodecLatin1::encodeCommon(const CharType* characters,
243 size_t length, 243 size_t length,
244 UnencodableHandling handling) { 244 UnencodableHandling handling) {
245 { 245 {
246 char* bytes; 246 char* bytes;
247 CString string = CString::newUninitialized(length, bytes); 247 CString string = CString::createUninitialized(length, bytes);
248 248
249 // Convert the string a fast way and simultaneously do an efficient check to 249 // Convert the string a fast way and simultaneously do an efficient check to
250 // see if it's all ASCII. 250 // see if it's all ASCII.
251 UChar ored = 0; 251 UChar ored = 0;
252 for (size_t i = 0; i < length; ++i) { 252 for (size_t i = 0; i < length; ++i) {
253 UChar c = characters[i]; 253 UChar c = characters[i];
254 bytes[i] = static_cast<char>(c); 254 bytes[i] = static_cast<char>(c);
255 ored |= c; 255 ored |= c;
256 } 256 }
257 257
(...skipping 11 matching lines...) Expand all
269 return encodeCommon(characters, length, handling); 269 return encodeCommon(characters, length, handling);
270 } 270 }
271 271
272 CString TextCodecLatin1::encode(const LChar* characters, 272 CString TextCodecLatin1::encode(const LChar* characters,
273 size_t length, 273 size_t length,
274 UnencodableHandling handling) { 274 UnencodableHandling handling) {
275 return encodeCommon(characters, length, handling); 275 return encodeCommon(characters, length, handling);
276 } 276 }
277 277
278 } // namespace WTF 278 } // namespace WTF
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/text/CStringTest.cpp ('k') | third_party/WebKit/Source/wtf/text/TextCodecUTF16.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698