diff options
| author | Carl Hetherington <cth@carlh.net> | 2026-04-15 23:07:24 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2026-04-15 23:07:24 +0200 |
| commit | 0466bf2201175e55d036f0510fd9a0b08b1d5d2f (patch) | |
| tree | b0419fb4a91830c1c9077f35e210c8aab0c4c65c | |
| parent | 6b8e08be8000824e2af0f24dbc86199dd427fcf6 (diff) | |
Move utf8_strlen() out to libdcp.
| -rw-r--r-- | cscript | 2 | ||||
| -rw-r--r-- | src/lib/hints.cc | 2 | ||||
| -rw-r--r-- | src/lib/util.cc | 20 | ||||
| -rw-r--r-- | src/lib/util.h | 1 | ||||
| -rw-r--r-- | test/util_test.cc | 8 |
5 files changed, 2 insertions, 31 deletions
@@ -506,7 +506,7 @@ def build_with_cpp17(target): def dependencies(target, options): - deps = [('libdcp', 'v1.10.55', {'c++17': build_with_cpp17(target)})] + deps = [('libdcp', '61c6b8a23ef6381c2d1b1aaa5bfc1e31e35a7ec0', {'c++17': build_with_cpp17(target)})] deps.append(('libsub', 'v1.6.59')) deps.append(('leqm-nrt', 'd75d0af984d9c14bfefca8f1bdbc215c3bf3a388')) if target.platform != 'linux' or target.distro != 'arch': diff --git a/src/lib/hints.cc b/src/lib/hints.cc index ac41b61b8..90b88a6ef 100644 --- a/src/lib/hints.cc +++ b/src/lib/hints.cc @@ -607,7 +607,7 @@ Hints::closed_caption(PlayerText text, DCPTimePeriod period) line.second.end(), 0, [](int acc, StringText const& text) { - return acc + utf8_strlen(text.text()); + return acc + dcp::utf8_strlen(text.text()); }); if (length > MAX_CLOSED_CAPTION_LENGTH && !_long_ccap) { diff --git a/src/lib/util.cc b/src/lib/util.cc index adc347ab1..1f5bec22c 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -842,26 +842,6 @@ remap(shared_ptr<const AudioBuffers> input, int output_channels, AudioMapping ma } -size_t -utf8_strlen(string s) -{ - size_t const len = s.length(); - int N = 0; - for (size_t i = 0; i < len; ++i) { - unsigned char c = s[i]; - if ((c & 0xe0) == 0xc0) { - ++i; - } else if ((c & 0xf0) == 0xe0) { - i += 2; - } else if ((c & 0xf8) == 0xf0) { - i += 3; - } - ++N; - } - return N; -} - - /** @param size Size of picture that the subtitle will be overlaid onto */ void emit_subtitle_image(ContentTimePeriod period, dcp::TextImage sub, dcp::Size size, shared_ptr<TextDecoder> decoder) diff --git a/src/lib/util.h b/src/lib/util.h index aa003ff00..9863e5d94 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -84,7 +84,6 @@ extern std::string atmos_asset_filename(std::shared_ptr<dcp::AtmosAsset> asset, extern std::string careful_string_filter(std::string s, std::wstring allowed = L"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_.+"); extern std::pair<int, int> audio_channel_types(std::list<int> mapped, int channels); extern std::shared_ptr<AudioBuffers> remap(std::shared_ptr<const AudioBuffers> input, int output_channels, AudioMapping map); -extern size_t utf8_strlen(std::string s); extern void emit_subtitle_image(dcpomatic::ContentTimePeriod period, dcp::TextImage sub, dcp::Size size, std::shared_ptr<TextDecoder> decoder); extern void copy_in_bits(boost::filesystem::path from, boost::filesystem::path to, std::function<void (float)>); extern dcp::Size scale_for_display(dcp::Size s, dcp::Size display_container, dcp::Size film_container, PixelQuanta quanta); diff --git a/test/util_test.cc b/test/util_test.cc index defc7f907..692fbf427 100644 --- a/test/util_test.cc +++ b/test/util_test.cc @@ -110,14 +110,6 @@ BOOST_AUTO_TEST_CASE(tidy_for_filename_test) } -BOOST_AUTO_TEST_CASE(utf8_strlen_test) -{ - BOOST_CHECK_EQUAL(utf8_strlen("hello world"), 11U); - BOOST_CHECK_EQUAL(utf8_strlen("hëllo world"), 11U); - BOOST_CHECK_EQUAL(utf8_strlen("hëłlo wørld"), 11U); -} - - BOOST_AUTO_TEST_CASE(careful_string_filter_test) { BOOST_CHECK_EQUAL("hello_world", careful_string_filter("hello_world")); |
