OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "platform/text/TextEncodingDetector.h" | 5 #include "platform/text/TextEncodingDetector.h" |
6 | 6 |
7 #include "platform/weborigin/KURL.h" | 7 #include "platform/weborigin/KURL.h" |
| 8 #include "platform/wtf/text/TextEncoding.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "wtf/text/TextEncoding.h" | |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 TEST(TextEncodingDetectorTest, RespectIso2022Jp) { | 13 TEST(TextEncodingDetectorTest, RespectIso2022Jp) { |
14 // ISO-2022-JP is the only 7-bit encoding defined in WHATWG standard. | 14 // ISO-2022-JP is the only 7-bit encoding defined in WHATWG standard. |
15 std::string iso2022jp = | 15 std::string iso2022jp = |
16 " \x1B" | 16 " \x1B" |
17 "$BKL3$F;F|K\\%O%`%U%!%$%?!<%:$,%=%U%H%P%s%/$H$N%W%l!<%*%U$r@)$7!\""; | 17 "$BKL3$F;F|K\\%O%`%U%!%$%?!<%:$,%=%U%H%P%s%/$H$N%W%l!<%*%U$r@)$7!\""; |
18 WTF::TextEncoding encoding; | 18 WTF::TextEncoding encoding; |
19 bool result = detectTextEncoding(iso2022jp.c_str(), iso2022jp.length(), | 19 bool result = detectTextEncoding(iso2022jp.c_str(), iso2022jp.length(), |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 "tnegirjji gosa gii beare s\xC3\xA1htt\xC3\xA1 \xC4\x8D\xC3" | 103 "tnegirjji gosa gii beare s\xC3\xA1htt\xC3\xA1 \xC4\x8D\xC3" |
104 "\xA1llit artihkkaliid. Maid don s\xC3\xA1ht\xC3\xA1t dievasmah"; | 104 "\xA1llit artihkkaliid. Maid don s\xC3\xA1ht\xC3\xA1t dievasmah"; |
105 WTF::TextEncoding encoding; | 105 WTF::TextEncoding encoding; |
106 KURL fileUrl(ParsedURLString, "file:///text.txt"); | 106 KURL fileUrl(ParsedURLString, "file:///text.txt"); |
107 bool result = detectTextEncoding(utf8Bytes.c_str(), utf8Bytes.length(), | 107 bool result = detectTextEncoding(utf8Bytes.c_str(), utf8Bytes.length(), |
108 nullptr, fileUrl, nullptr, &encoding); | 108 nullptr, fileUrl, nullptr, &encoding); |
109 EXPECT_TRUE(result); | 109 EXPECT_TRUE(result); |
110 } | 110 } |
111 | 111 |
112 } // namespace blink | 112 } // namespace blink |
OLD | NEW |