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

Side by Side Diff: Source/wtf/text/TextCodecUTF8.cpp

Issue 23532016: Handle odd data lengths in UTF-16 decoder (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Simplify Created 6 years, 9 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 | « Source/wtf/text/TextCodecUTF8.h ('k') | Source/wtf/text/TextCodecUTF8Test.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2006, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 2008, 2011 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 continue; 258 continue;
259 } 259 }
260 260
261 m_partialSequenceSize -= count; 261 m_partialSequenceSize -= count;
262 destination = appendCharacter(destination, character); 262 destination = appendCharacter(destination, character);
263 } while (m_partialSequenceSize); 263 } while (m_partialSequenceSize);
264 264
265 return false; 265 return false;
266 } 266 }
267 267
268 String TextCodecUTF8::decode(const char* bytes, size_t length, bool flush, bool stopOnError, bool& sawError) 268 String TextCodecUTF8::decode(const char* bytes, size_t length, FlushBehavior flu sh, bool stopOnError, bool& sawError)
269 { 269 {
270 // Each input byte might turn into a character. 270 // Each input byte might turn into a character.
271 // That includes all bytes in the partial-sequence buffer because 271 // That includes all bytes in the partial-sequence buffer because
272 // each byte in an invalid sequence will turn into a replacement character. 272 // each byte in an invalid sequence will turn into a replacement character.
273 StringBuffer<LChar> buffer(m_partialSequenceSize + length); 273 StringBuffer<LChar> buffer(m_partialSequenceSize + length);
274 274
275 const uint8_t* source = reinterpret_cast<const uint8_t*>(bytes); 275 const uint8_t* source = reinterpret_cast<const uint8_t*>(bytes);
276 const uint8_t* end = source + length; 276 const uint8_t* end = source + length;
277 const uint8_t* alignedEnd = alignToMachineWord(end); 277 const uint8_t* alignedEnd = alignToMachineWord(end);
278 LChar* destination = buffer.characters(); 278 LChar* destination = buffer.characters();
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 { 454 {
455 return encodeCommon(characters, length); 455 return encodeCommon(characters, length);
456 } 456 }
457 457
458 CString TextCodecUTF8::encode(const LChar* characters, size_t length, Unencodabl eHandling) 458 CString TextCodecUTF8::encode(const LChar* characters, size_t length, Unencodabl eHandling)
459 { 459 {
460 return encodeCommon(characters, length); 460 return encodeCommon(characters, length);
461 } 461 }
462 462
463 } // namespace WTF 463 } // namespace WTF
OLDNEW
« no previous file with comments | « Source/wtf/text/TextCodecUTF8.h ('k') | Source/wtf/text/TextCodecUTF8Test.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698