statusbar: use boost::format instead of c-style printf
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include <boost/locale/encoding.hpp>
|
||||
#include <cassert>
|
||||
#include "utility/wide_string.h"
|
||||
|
||||
std::string ToString(std::wstring ws)
|
||||
@@ -34,10 +35,8 @@ std::wstring ToWString(std::string s)
|
||||
size_t wideLength(const std::wstring &ws)
|
||||
{
|
||||
int len = wcswidth(ws.c_str(), -1);
|
||||
if (len < 0)
|
||||
return ws.length();
|
||||
else
|
||||
return len;
|
||||
assert(len >= 0);
|
||||
return len;
|
||||
}
|
||||
|
||||
void wideCut(std::wstring &ws, size_t max_length)
|
||||
|
||||
@@ -31,4 +31,9 @@ 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);
|
||||
|
||||
inline std::string wideShorten(const std::string &s, size_t max_length)
|
||||
{
|
||||
return ToString(wideShorten(ToWString(s), max_length));
|
||||
}
|
||||
|
||||
#endif // NCMPCPP_UTILITY_WIDE_STRING_h
|
||||
|
||||
Reference in New Issue
Block a user