From 2497198e9599a6a8d4d0ad08627bcfc7ea49c644 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9=20=D0=A8=D0=B8?= =?UTF-8?q?=D0=BB=D0=B8=D0=BD?= Date: Sat, 23 Nov 2019 01:04:45 +0300 Subject: Fix progress bar width for multibyte charsets When using locale in which symbols occupy more than 1 byte (for example, ru_RU.UTF-8), the progress bar width was calculated incorrectly because std::string::size() returns the number of bytes rather than the number of actual characters. Use the newly introduced APT::String::DisplayLength() to calculate the width instead. --- apt-pkg/install-progress.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-pkg/install-progress.cc b/apt-pkg/install-progress.cc index 2e8fac236..aadd28e51 100644 --- a/apt-pkg/install-progress.cc +++ b/apt-pkg/install-progress.cc @@ -382,7 +382,7 @@ bool PackageManagerFancy::DrawStatusLine() if (_config->FindB("Dpkg::Progress-Fancy::Progress-Bar", true)) { int padding = 4; - auto const progressbar_size = size.columns - padding - progress_str.size(); + auto const progressbar_size = size.columns - padding - String::DisplayLength(progress_str); auto const current_percent = percentage / 100.0f; std::cout << " " << GetTextProgressStr(current_percent, progressbar_size) -- cgit v1.2.3