Commit f4b808dc authored by Alexander A. Maly's avatar Alexander A. Maly

Added useful string conversions to Core

parent 01e5a039
...@@ -137,20 +137,40 @@ public: ...@@ -137,20 +137,40 @@ public:
static void finalize() {} static void finalize() {}
static String fromUtf8(const std::string &s) static String fromEncoding(Encoding enc, const std::string &s)
{ {
EncodingError encodingError; EncodingError encodingError;
String result = Coder::decode(UTF8, s, encodingError); String result = Coder::decode(enc, s, encodingError);
return result; return result;
} }
static String fromAscii(const std::string &s) static std::string toEncoding(Encoding enc, const String &s)
{ {
EncodingError encodingError; EncodingError encodingError;
String result = Coder::decode(ASCII, s, encodingError); std::string result = Coder::encode(enc, s, encodingError);
return result; return result;
} }
static String fromAscii(const std::string &s)
{
return fromEncoding(ASCII, s);
}
static std::string toAscii(const String &s)
{
return toEncoding(ASCII, s);
}
static String fromUtf8(const std::string &s)
{
return fromEncoding(UTF8, s);
}
static std::string toUtf8(const String &s)
{
return toEncoding(UTF8, s);
}
static std::string toLowerCase(const std::string &s); static std::string toLowerCase(const std::string &s);
static std::string toUpperCase(const std::string &s); static std::string toUpperCase(const std::string &s);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment