summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorАлексей Шилин <rootlexx@mail.ru>2019-11-23 01:04:45 +0300
committerАлексей Шилин <rootlexx@mail.ru>2019-11-25 19:03:10 +0300
commit2497198e9599a6a8d4d0ad08627bcfc7ea49c644 (patch)
tree3d8f6ece94bf89c4ed7aa57352fe98a9d4eb3ffb
parent6ad35af2b63b32f9070c622b69da1c05535086a0 (diff)
downloadapt-2497198e9599a6a8d4d0ad08627bcfc7ea49c644.tar.gz
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.
-rw-r--r--apt-pkg/install-progress.cc2
1 files changed, 1 insertions, 1 deletions
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)