diff options
| author | Carl Hetherington <cth@carlh.net> | 2019-01-23 21:44:20 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2019-01-23 21:44:20 +0000 |
| commit | 014bb19876f5b26b9802fa42b573c333ebc09139 (patch) | |
| tree | 70e0d2f118fe64cb7f1e79037b251b69f0dd5f40 /test/subrip_reader_test.cc | |
| parent | 1e1836a2010a9cf421736b25aa0a9f30a268a68b (diff) | |
Strip Unicode U+202B (right-to-left-embedding) code; it looks like DoM does RTL (at least) partially correctly without this.
Diffstat (limited to 'test/subrip_reader_test.cc')
| -rw-r--r-- | test/subrip_reader_test.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/subrip_reader_test.cc b/test/subrip_reader_test.cc index f323f6a..c2702c4 100644 --- a/test/subrip_reader_test.cc +++ b/test/subrip_reader_test.cc @@ -501,3 +501,27 @@ BOOST_AUTO_TEST_CASE (subrip_reader_test3) BLOCK ("Both lines are bold AND italic", "Arial", 30, true, true, false); SUB_END (); } + +/** Test reading of a .srt file with RTL text */ +BOOST_AUTO_TEST_CASE (subrip_reader_test4) +{ + boost::filesystem::path p = private_test / "rtl.srt"; + FILE* f = fopen (p.string().c_str(), "r"); + sub::SubripReader reader (f); + fclose (f); + list<sub::Subtitle> subs = sub::collect<std::list<sub::Subtitle> >(reader.subtitles()); + + list<sub::Subtitle>::iterator i = subs.begin (); + std::cout << i->lines.front().blocks.front().text << "\n"; + + std::string const t = i->lines.front().blocks.front().text; + for (size_t i = 0; i < t.length() - 2; ++i) { + /* Check that unicode U+202B (right-to-left embedding) has been stripped */ + unsigned char const a = t[i]; + unsigned char const b = t[i+1]; + unsigned char const c = t[i+2]; + BOOST_CHECK ((a != 0xe2 || b != 0x80 || c != 0xab)); + } + + BOOST_CHECK (t == "- \"(دريه فابينار)\""); +} |
