--- a/sources/mystring.h Wed Jul 20 22:56:16 2016 +0300 +++ b/sources/mystring.h Fri Jul 22 17:50:00 2016 +0300 @@ -93,6 +93,7 @@ const std::string& stdString() const; void strip(char unwanted); void strip(const List<char> &unwanted); + const unsigned char* toBytes() const; double toDouble(bool* ok = nullptr) const; float toFloat(bool* ok = nullptr) const; long toInt(bool* ok = nullptr, int base = 10) const; @@ -107,6 +108,7 @@ static String fromNumber(unsigned int a); static String fromNumber(unsigned long int a); static String fromNumber(double a); + static String fromBytes(const Vector<unsigned char>& bytes); String operator+(const String& data) const; String operator+(const char* data) const; @@ -553,6 +555,14 @@ } /*! + * \returns the underlying char-array representation of this string, casted to unsigned chars. + */ +inline const unsigned char* String::toBytes() const +{ + return reinterpret_cast<const unsigned char*>(chars()); +} + +/*! * \brief Constructs an empty string list. */ inline StringList::StringList() {}