PIIOTextStream for strings fix
This commit is contained in:
@@ -3,7 +3,7 @@ cmake_policy(SET CMP0017 NEW) # need include() with .cmake
|
||||
project(PIP)
|
||||
set(PIP_MAJOR 3)
|
||||
set(PIP_MINOR 10)
|
||||
set(PIP_REVISION 0)
|
||||
set(PIP_REVISION 1)
|
||||
set(PIP_SUFFIX )
|
||||
set(PIP_COMPANY SHS)
|
||||
set(PIP_DOMAIN org.SHS)
|
||||
|
||||
@@ -81,7 +81,7 @@ ssize_t PIIOString::writeDevice(const void * data, ssize_t max_size) {
|
||||
if (!canWrite() || !str) return -1;
|
||||
// piCout << "write" << data;
|
||||
if (pos > str->size_s()) pos = str->size_s();
|
||||
PIString rs = PIString::fromUTF8((const char *)data);
|
||||
PIString rs = PIString::fromUTF8((const char *)data, max_size);
|
||||
if (rs.size_s() > max_size) rs.resize(max_size);
|
||||
str->insert(pos, rs);
|
||||
pos += rs.size_s();
|
||||
|
||||
@@ -356,15 +356,16 @@ PIString PIString::fromSystem(const char * s) {
|
||||
}
|
||||
|
||||
|
||||
PIString PIString::fromUTF8(const char * s) {
|
||||
PIString PIString::fromUTF8(const char * s, int l) {
|
||||
PIString ret;
|
||||
if (!s) return ret;
|
||||
if (s[0] != '\0') {
|
||||
if ((uchar)s[0] == 0xEF && (uchar)s[1] == 0xBB && (uchar)s[2] == 0xBF) {
|
||||
s += 3;
|
||||
if (l > 0) l -= 3;
|
||||
if (s[0] == '\0') return ret;
|
||||
}
|
||||
ret.appendFromChars(s, -1, __utf8name__);
|
||||
ret.appendFromChars(s, l, __utf8name__);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1700,7 +1700,7 @@ public:
|
||||
|
||||
//! \~english Returns string constructed from UTF-8.
|
||||
//! \~russian Возвращает строку созданную из UTF-8.
|
||||
static PIString fromUTF8(const char * s);
|
||||
static PIString fromUTF8(const char * s, int l = -1);
|
||||
|
||||
//! \~english Returns string constructed from UTF-8.
|
||||
//! \~russian Возвращает строку созданную из UTF-8.
|
||||
|
||||
Reference in New Issue
Block a user