OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2011 Apple Inc. All rights reserved. |
3 * Copyright (C) 2007-2009 Torch Mobile, Inc. | 3 * Copyright (C) 2007-2009 Torch Mobile, Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "wtf/CurrentTime.h" | 31 #include "wtf/CurrentTime.h" |
32 #include "wtf/HashMap.h" | 32 #include "wtf/HashMap.h" |
33 #include "wtf/HashSet.h" | 33 #include "wtf/HashSet.h" |
34 #include "wtf/MainThread.h" | 34 #include "wtf/MainThread.h" |
35 #include "wtf/StdLibExtras.h" | 35 #include "wtf/StdLibExtras.h" |
36 #include "wtf/StringExtras.h" | 36 #include "wtf/StringExtras.h" |
37 #include "wtf/ThreadingPrimitives.h" | 37 #include "wtf/ThreadingPrimitives.h" |
38 #include "wtf/text/CString.h" | 38 #include "wtf/text/CString.h" |
39 #include "wtf/text/TextCodecICU.h" | 39 #include "wtf/text/TextCodecICU.h" |
40 #include "wtf/text/TextCodecLatin1.h" | 40 #include "wtf/text/TextCodecLatin1.h" |
| 41 #include "wtf/text/TextCodecReplacement.h" |
41 #include "wtf/text/TextCodecUTF16.h" | 42 #include "wtf/text/TextCodecUTF16.h" |
42 #include "wtf/text/TextCodecUTF8.h" | 43 #include "wtf/text/TextCodecUTF8.h" |
43 #include "wtf/text/TextCodecUserDefined.h" | 44 #include "wtf/text/TextCodecUserDefined.h" |
44 #include "wtf/text/TextEncoding.h" | 45 #include "wtf/text/TextEncoding.h" |
45 | 46 |
46 namespace WTF { | 47 namespace WTF { |
47 | 48 |
48 const size_t maxEncodingNameLength = 63; | 49 const size_t maxEncodingNameLength = 63; |
49 | 50 |
50 // Hash for all-ASCII strings that does case folding. | 51 // Hash for all-ASCII strings that does case folding. |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 TextCodecLatin1::registerCodecs(addToTextCodecMap); | 214 TextCodecLatin1::registerCodecs(addToTextCodecMap); |
214 | 215 |
215 TextCodecUTF8::registerEncodingNames(addToTextEncodingNameMap); | 216 TextCodecUTF8::registerEncodingNames(addToTextEncodingNameMap); |
216 TextCodecUTF8::registerCodecs(addToTextCodecMap); | 217 TextCodecUTF8::registerCodecs(addToTextCodecMap); |
217 | 218 |
218 TextCodecUTF16::registerEncodingNames(addToTextEncodingNameMap); | 219 TextCodecUTF16::registerEncodingNames(addToTextEncodingNameMap); |
219 TextCodecUTF16::registerCodecs(addToTextCodecMap); | 220 TextCodecUTF16::registerCodecs(addToTextCodecMap); |
220 | 221 |
221 TextCodecUserDefined::registerEncodingNames(addToTextEncodingNameMap); | 222 TextCodecUserDefined::registerEncodingNames(addToTextEncodingNameMap); |
222 TextCodecUserDefined::registerCodecs(addToTextCodecMap); | 223 TextCodecUserDefined::registerCodecs(addToTextCodecMap); |
| 224 |
| 225 TextCodecReplacement::registerEncodingNames(addToTextEncodingNameMap); |
| 226 TextCodecReplacement::registerCodecs(addToTextCodecMap); |
| 227 // The "replacement" codec should not be referenceable by name. |
| 228 textEncodingNameMap->remove("replacement"); |
223 } | 229 } |
224 | 230 |
225 static void addEncodingName(HashSet<const char*>* set, const char* name) | 231 static void addEncodingName(HashSet<const char*>* set, const char* name) |
226 { | 232 { |
227 // We must not use atomicCanonicalTextEncodingName() because this function i
s called in it. | 233 // We must not use atomicCanonicalTextEncodingName() because this function i
s called in it. |
228 const char* atomicName = textEncodingNameMap->get(name); | 234 const char* atomicName = textEncodingNameMap->get(name); |
229 if (atomicName) | 235 if (atomicName) |
230 set->add(atomicName); | 236 set->add(atomicName); |
231 } | 237 } |
232 | 238 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 MutexLocker lock(encodingRegistryMutex()); | 359 MutexLocker lock(encodingRegistryMutex()); |
354 | 360 |
355 TextEncodingNameMap::const_iterator it = textEncodingNameMap->begin(); | 361 TextEncodingNameMap::const_iterator it = textEncodingNameMap->begin(); |
356 TextEncodingNameMap::const_iterator end = textEncodingNameMap->end(); | 362 TextEncodingNameMap::const_iterator end = textEncodingNameMap->end(); |
357 for (; it != end; ++it) | 363 for (; it != end; ++it) |
358 fprintf(stderr, "'%s' => '%s'\n", it->key, it->value); | 364 fprintf(stderr, "'%s' => '%s'\n", it->key, it->value); |
359 } | 365 } |
360 #endif | 366 #endif |
361 | 367 |
362 } // namespace WTF | 368 } // namespace WTF |
OLD | NEW |