1 // Copyright 2013 Samsung Electronics. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "text_encoding_map_efl.h"
13 // The below Encodings have been taken from
14 // chromium/src/third_party/WebKit/Source/wtf/text/TextCodecLatin1.cpp
15 // chromium/src/third_party/WebKit/Source/wtf/text/TextCodecUTF8.cpp
16 // chromium/src/third_party/WebKit/Source/wtf/text/TextCodecUserDefined.cpp
17 // chromium/src/third_party/WebKit/Source/wtf/text/TextCodecUTF16.cpp
18 // chromium/src/third_party/WebKit/Source/wtf/text/TextCodecICU.cpp
20 // The TextEncodingNameMap(present in
21 // /chromium/src/third_party/WebKit/Source/wtf/text/TextEncodingRegistry.cpp)
22 // is contructed by combining the Encodings and aliases present in the above
25 // The character encoding list used by chrome browser is also used as reference.
27 // chromium/src/chrome/browser/character_encoding.cc
29 const std::vector<std::string> TextEncodingNameMap = {
30 "windows-1252", "ISO-8859-1", "US-ASCII", "UTF-8",
31 "UTF-16LE", "UTF-16BE", "x-user-defined", "ISO-8859-8-I",
32 "GBK", "GB_2312-80", "EUC-KR", "Windows-1254",
33 "Windows-874", "Big5", "macintosh", "EUC-JP",
34 "Big5-HKSCS", "Shift_JIS", "EUC-JP", "ISO-2022-JP",
35 "windows-874", "windows-949", "ISO-8859-15", "ISO-8859-2",
36 "windows-1250", "windows-1251", "windows-1258", "KOI8-R",
37 "ISO-8859-7", "windows-1253", "windows-1256", "windows-1257",
38 "ISO-8859-8", "windows-1254", "windows-1255", "ISO-8859-6",
39 "ISO-8859-1", "ISO-8859-3", "ISO-8859-4", "ISO-8859-10",
40 "ISO-8859-13", "ISO-8859-14", "ISO-8859-5", "ISO-8859-9",
41 "cp864", "x-mac-cyrillic"};
46 TextEncodingMapEfl* TextEncodingMapEfl::GetInstance() {
47 return base::Singleton<TextEncodingMapEfl>::get();
50 bool TextEncodingMapEfl::isTextEncodingValid(const char* name) {
51 if (!name || !name[0])
54 std::string str(name);
55 std::transform(str.begin(), str.end(), str.begin(), ::tolower);
56 return encoding_name_set_.find(str) != encoding_name_set_.end();
59 TextEncodingMapEfl::TextEncodingMapEfl() {
60 for (size_t i = 0; i < TextEncodingNameMap.size(); i++) {
61 std::string name = TextEncodingNameMap[i];
62 std::transform(name.begin(), name.end(), name.begin(), ::tolower);
63 encoding_name_set_.insert(name);