| OLD | NEW |
| 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 |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "wtf/text/TextCodecLatin1.h" | 26 #include "wtf/text/TextCodecLatin1.h" |
| 27 | 27 |
| 28 #include "wtf/PassOwnPtr.h" | 28 #include "wtf/PtrUtil.h" |
| 29 #include "wtf/text/CString.h" | 29 #include "wtf/text/CString.h" |
| 30 #include "wtf/text/StringBuffer.h" | 30 #include "wtf/text/StringBuffer.h" |
| 31 #include "wtf/text/TextCodecASCIIFastPath.h" | 31 #include "wtf/text/TextCodecASCIIFastPath.h" |
| 32 #include "wtf/text/WTFString.h" | 32 #include "wtf/text/WTFString.h" |
| 33 #include <memory> |
| 33 | 34 |
| 34 namespace WTF { | 35 namespace WTF { |
| 35 | 36 |
| 36 static const UChar table[256] = { | 37 static const UChar table[256] = { |
| 37 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, // 00-07 | 38 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, // 00-07 |
| 38 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F, // 08-0F | 39 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F, // 08-0F |
| 39 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, // 10-17 | 40 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, // 10-17 |
| 40 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F, // 18-1F | 41 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F, // 18-1F |
| 41 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, // 20-27 | 42 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, // 20-27 |
| 42 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, // 28-2F | 43 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, // 28-2F |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 registrar("iso8859-1", "windows-1252"); | 84 registrar("iso8859-1", "windows-1252"); |
| 84 registrar("iso88591", "windows-1252"); | 85 registrar("iso88591", "windows-1252"); |
| 85 registrar("iso_8859-1", "windows-1252"); | 86 registrar("iso_8859-1", "windows-1252"); |
| 86 registrar("iso_8859-1:1987", "windows-1252"); | 87 registrar("iso_8859-1:1987", "windows-1252"); |
| 87 registrar("l1", "windows-1252"); | 88 registrar("l1", "windows-1252"); |
| 88 registrar("latin1", "windows-1252"); | 89 registrar("latin1", "windows-1252"); |
| 89 registrar("US-ASCII", "windows-1252"); | 90 registrar("US-ASCII", "windows-1252"); |
| 90 registrar("x-cp1252", "windows-1252"); | 91 registrar("x-cp1252", "windows-1252"); |
| 91 } | 92 } |
| 92 | 93 |
| 93 static PassOwnPtr<TextCodec> newStreamingTextDecoderWindowsLatin1(const TextEnco
ding&, const void*) | 94 static std::unique_ptr<TextCodec> newStreamingTextDecoderWindowsLatin1(const Tex
tEncoding&, const void*) |
| 94 { | 95 { |
| 95 return adoptPtr(new TextCodecLatin1); | 96 return wrapUnique(new TextCodecLatin1); |
| 96 } | 97 } |
| 97 | 98 |
| 98 void TextCodecLatin1::registerCodecs(TextCodecRegistrar registrar) | 99 void TextCodecLatin1::registerCodecs(TextCodecRegistrar registrar) |
| 99 { | 100 { |
| 100 registrar("windows-1252", newStreamingTextDecoderWindowsLatin1, 0); | 101 registrar("windows-1252", newStreamingTextDecoderWindowsLatin1, 0); |
| 101 | 102 |
| 102 // ASCII and Latin-1 both decode as Windows Latin-1 although they retain uni
que identities. | 103 // ASCII and Latin-1 both decode as Windows Latin-1 although they retain uni
que identities. |
| 103 registrar("ISO-8859-1", newStreamingTextDecoderWindowsLatin1, 0); | 104 registrar("ISO-8859-1", newStreamingTextDecoderWindowsLatin1, 0); |
| 104 registrar("US-ASCII", newStreamingTextDecoderWindowsLatin1, 0); | 105 registrar("US-ASCII", newStreamingTextDecoderWindowsLatin1, 0); |
| 105 } | 106 } |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 { | 260 { |
| 260 return encodeCommon(characters, length, handling); | 261 return encodeCommon(characters, length, handling); |
| 261 } | 262 } |
| 262 | 263 |
| 263 CString TextCodecLatin1::encode(const LChar* characters, size_t length, Unencoda
bleHandling handling) | 264 CString TextCodecLatin1::encode(const LChar* characters, size_t length, Unencoda
bleHandling handling) |
| 264 { | 265 { |
| 265 return encodeCommon(characters, length, handling); | 266 return encodeCommon(characters, length, handling); |
| 266 } | 267 } |
| 267 | 268 |
| 268 } // namespace WTF | 269 } // namespace WTF |
| OLD | NEW |