summaryrefslogtreecommitdiff
path: root/src/utils.cpp
diff options
context:
space:
mode:
authorGravatar Stefan Erben <stefan@erben.com> 2009-08-04 11:47:42 +0200
committerGravatar Andreas Krennmair <ak@synflood.at> 2009-08-04 13:57:35 +0200
commit3c1ea127c553ba28904aa15816a2d9bd115ed9dd (patch)
treed99b6f34e2b7a11f39aa4203b90b6a2db0ae5dfb /src/utils.cpp
parent1dff5fe5a929f746275ac1ccade5a57728643762 (diff)
downloadnewsboat-3c1ea127c553ba28904aa15816a2d9bd115ed9dd.tar.gz
newsboat-3c1ea127c553ba28904aa15816a2d9bd115ed9dd.tar.zst
newsboat-3c1ea127c553ba28904aa15816a2d9bd115ed9dd.zip
utils:: strwidth() returned npos, if a char in the string is non-printable (see wcswidth(3)).
Diffstat (limited to '')
-rw-r--r--src/utils.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/utils.cpp b/src/utils.cpp
index c72a3fbd..6c85d5d1 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -602,7 +602,10 @@ std::vector<std::pair<unsigned int, unsigned int> > utils::partition_indexes(uns
size_t utils::strwidth(const std::string& str) {
std::wstring wstr = str2wstr(str);
- return wcswidth(wstr.c_str(), wstr.length());
+ int width = wcswidth(wstr.c_str(), wstr.length());
+ if (width < 1) // a non-printable character found?
+ return wstr.length(); // return a sane width (which might be larger than necessary)
+ return width; // exact width
}
std::string utils::join(const std::vector<std::string>& strings, const std::string& separator) {