summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lyrics.cpp2
-rw-r--r--src/utility/wide_string.cpp10
-rw-r--r--src/utility/wide_string.h7
3 files changed, 9 insertions, 10 deletions
diff --git a/src/lyrics.cpp b/src/lyrics.cpp
index 2d0450ff..3677a72e 100644
--- a/src/lyrics.cpp
+++ b/src/lyrics.cpp
@@ -129,7 +129,7 @@ std::wstring Lyrics::title()
std::wstring result = L"Lyrics: ";
result += Scroller(
- Format::stringify<wchar_t>(Format::wparse(L"{%a - %t}"), &itsSong),
+ Format::stringify<wchar_t>(Format::wparse(L"%a - %t"), &itsSong),
itsScrollBegin,
COLS-result.length()-(Config.design == Design::Alternative ? 2 : Global::VolumeState.length())
);
diff --git a/src/utility/wide_string.cpp b/src/utility/wide_string.cpp
index ee1193ca..3f214558 100644
--- a/src/utility/wide_string.cpp
+++ b/src/utility/wide_string.cpp
@@ -22,14 +22,14 @@
#include <cassert>
#include "utility/wide_string.h"
-std::string ToString(std::wstring ws)
+std::string ToString(const std::wstring &ws)
{
- return boost::locale::conv::utf_to_utf<char>(std::move(ws));
+ return boost::locale::conv::utf_to_utf<char>(ws);
}
-std::wstring ToWString(std::string s)
+std::wstring ToWString(const std::string &s)
{
- return boost::locale::conv::utf_to_utf<wchar_t>(std::move(s));
+ return boost::locale::conv::utf_to_utf<wchar_t>(s);
}
size_t wideLength(const std::wstring &ws)
@@ -52,7 +52,7 @@ void wideCut(std::wstring &ws, size_t max_length)
int remained_len = max_length;
for (; i < ws.length(); ++i)
{
- remained_len -= wcwidth(ws[i]);
+ remained_len -= std::max(wcwidth(ws[i]), 1);
if (remained_len < 0)
{
ws.resize(i);
diff --git a/src/utility/wide_string.h b/src/utility/wide_string.h
index 774aeb15..076dfe95 100644
--- a/src/utility/wide_string.h
+++ b/src/utility/wide_string.h
@@ -23,14 +23,13 @@
#include <string>
-std::string ToString(std::wstring ws);
-std::wstring ToWString(std::string s);
+std::string ToString(const std::wstring &ws);
+std::wstring ToWString(const std::string &s);
size_t wideLength(const std::wstring &ws);
-
void wideCut(std::wstring &ws, size_t max_length);
-std::wstring wideShorten(const std::wstring &ws, size_t max_length);
+std::wstring wideShorten(const std::wstring &ws, size_t max_length);
inline std::string wideShorten(const std::string &s, size_t max_length)
{
return ToString(wideShorten(ToWString(s), max_length));