format: fix error reporting with wide strings

This commit is contained in:
Andrzej Rybczak
2014-11-11 00:59:24 +01:00
parent 25ac152b0d
commit 50bfec9646
3 changed files with 27 additions and 18 deletions

View File

@@ -21,6 +21,7 @@
#ifndef NCMPCPP_UTILITY_FUNCTIONAL_H
#define NCMPCPP_UTILITY_FUNCTIONAL_H
#include <boost/locale/encoding_utf.hpp>
#include <utility>
// identity function object
@@ -34,4 +35,23 @@ struct id_
}
};
// convert string to appropriate type
template <typename TargetT, typename SourceT>
struct convertString
{
static std::basic_string<TargetT> apply(const std::basic_string<SourceT> &s)
{
return boost::locale::conv::utf_to_utf<TargetT>(s);
}
};
template <typename TargetT>
struct convertString<TargetT, TargetT>
{
static const std::basic_string<TargetT> &apply(const std::basic_string<TargetT> &s)
{
return s;
}
};
#endif // NCMPCPP_UTILITY_FUNCTIONAL_H