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

Side by Side Diff: Source/wtf/text/TextCodecUserDefined.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/TextCodecUserDefined.h ('k') | Source/wtf/text/TextEncoding.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) 2007, 2008 Apple, Inc. All rights reserved. 2 * Copyright (C) 2007, 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 static PassOwnPtr<TextCodec> newStreamingTextDecoderUserDefined(const TextEncodi ng&, const void*) 42 static PassOwnPtr<TextCodec> newStreamingTextDecoderUserDefined(const TextEncodi ng&, const void*)
43 { 43 {
44 return adoptPtr(new TextCodecUserDefined); 44 return adoptPtr(new TextCodecUserDefined);
45 } 45 }
46 46
47 void TextCodecUserDefined::registerCodecs(TextCodecRegistrar registrar) 47 void TextCodecUserDefined::registerCodecs(TextCodecRegistrar registrar)
48 { 48 {
49 registrar("x-user-defined", newStreamingTextDecoderUserDefined, 0); 49 registrar("x-user-defined", newStreamingTextDecoderUserDefined, 0);
50 } 50 }
51 51
52 String TextCodecUserDefined::decode(const char* bytes, size_t length, bool, bool , bool&) 52 String TextCodecUserDefined::decode(const char* bytes, size_t length, FlushBehav ior, bool, bool&)
53 { 53 {
54 StringBuilder result; 54 StringBuilder result;
55 result.reserveCapacity(length); 55 result.reserveCapacity(length);
56 56
57 for (size_t i = 0; i < length; ++i) { 57 for (size_t i = 0; i < length; ++i) {
58 signed char c = bytes[i]; 58 signed char c = bytes[i];
59 result.append(static_cast<UChar>(c & 0xF7FF)); 59 result.append(static_cast<UChar>(c & 0xF7FF));
60 } 60 }
61 61
62 return result.toString(); 62 return result.toString();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 { 114 {
115 return encodeCommon(characters, length, handling); 115 return encodeCommon(characters, length, handling);
116 } 116 }
117 117
118 CString TextCodecUserDefined::encode(const LChar* characters, size_t length, Une ncodableHandling handling) 118 CString TextCodecUserDefined::encode(const LChar* characters, size_t length, Une ncodableHandling handling)
119 { 119 {
120 return encodeCommon(characters, length, handling); 120 return encodeCommon(characters, length, handling);
121 } 121 }
122 122
123 } // namespace WTF 123 } // namespace WTF
OLDNEW
« no previous file with comments | « Source/wtf/text/TextCodecUserDefined.h ('k') | Source/wtf/text/TextEncoding.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698