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

Side by Side Diff: Source/wtf/text/TextCodecLatin1.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/TextCodecLatin1.h ('k') | Source/wtf/text/TextCodecUTF16.h » ('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 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 void TextCodecLatin1::registerCodecs(TextCodecRegistrar registrar) 112 void TextCodecLatin1::registerCodecs(TextCodecRegistrar registrar)
113 { 113 {
114 registrar("windows-1252", newStreamingTextDecoderWindowsLatin1, 0); 114 registrar("windows-1252", newStreamingTextDecoderWindowsLatin1, 0);
115 115
116 // ASCII and Latin-1 both decode as Windows Latin-1 although they retain uni que identities. 116 // ASCII and Latin-1 both decode as Windows Latin-1 although they retain uni que identities.
117 registrar("ISO-8859-1", newStreamingTextDecoderWindowsLatin1, 0); 117 registrar("ISO-8859-1", newStreamingTextDecoderWindowsLatin1, 0);
118 registrar("US-ASCII", newStreamingTextDecoderWindowsLatin1, 0); 118 registrar("US-ASCII", newStreamingTextDecoderWindowsLatin1, 0);
119 } 119 }
120 120
121 String TextCodecLatin1::decode(const char* bytes, size_t length, bool, bool, boo l&) 121 String TextCodecLatin1::decode(const char* bytes, size_t length, FlushBehavior, bool, bool&)
122 { 122 {
123 LChar* characters; 123 LChar* characters;
124 if (!length) 124 if (!length)
125 return emptyString(); 125 return emptyString();
126 String result = String::createUninitialized(length, characters); 126 String result = String::createUninitialized(length, characters);
127 127
128 const uint8_t* source = reinterpret_cast<const uint8_t*>(bytes); 128 const uint8_t* source = reinterpret_cast<const uint8_t*>(bytes);
129 const uint8_t* end = reinterpret_cast<const uint8_t*>(bytes + length); 129 const uint8_t* end = reinterpret_cast<const uint8_t*>(bytes + length);
130 const uint8_t* alignedEnd = alignToMachineWord(end); 130 const uint8_t* alignedEnd = alignToMachineWord(end);
131 LChar* destination = characters; 131 LChar* destination = characters;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 { 272 {
273 return encodeCommon(characters, length, handling); 273 return encodeCommon(characters, length, handling);
274 } 274 }
275 275
276 CString TextCodecLatin1::encode(const LChar* characters, size_t length, Unencoda bleHandling handling) 276 CString TextCodecLatin1::encode(const LChar* characters, size_t length, Unencoda bleHandling handling)
277 { 277 {
278 return encodeCommon(characters, length, handling); 278 return encodeCommon(characters, length, handling);
279 } 279 }
280 280
281 } // namespace WTF 281 } // namespace WTF
OLDNEW
« no previous file with comments | « Source/wtf/text/TextCodecLatin1.h ('k') | Source/wtf/text/TextCodecUTF16.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698