mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 15:38:00 +02:00
Transmit octree string parameters as utf-8 strings
This commit is contained in:
parent
66d5b16a5d
commit
05d56a5fe9
1 changed files with 22 additions and 21 deletions
7
libraries/octree/src/OctreePacketData.cpp
Normal file → Executable file
7
libraries/octree/src/OctreePacketData.cpp
Normal file → Executable file
|
@ -506,10 +506,11 @@ bool OctreePacketData::appendValue(bool value) {
|
|||
|
||||
bool OctreePacketData::appendValue(const QString& string) {
|
||||
// TODO: make this a ByteCountCoded leading byte
|
||||
uint16_t length = string.size() + 1; // include NULL
|
||||
QByteArray utf8Array = string.toUtf8();
|
||||
uint16_t length = utf8Array.length(); // no NULL
|
||||
bool success = appendValue(length);
|
||||
if (success) {
|
||||
success = appendRawData((const unsigned char*)qPrintable(string), length);
|
||||
success = appendRawData((const unsigned char*)utf8Array.constData(), length);
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
@ -706,7 +707,7 @@ int OctreePacketData::unpackDataFromBytes(const unsigned char* dataBytes, QStrin
|
|||
uint16_t length;
|
||||
memcpy(&length, dataBytes, sizeof(length));
|
||||
dataBytes += sizeof(length);
|
||||
QString value((const char*)dataBytes);
|
||||
QString value = QString::fromUtf8((const char*)dataBytes, length);
|
||||
result = value;
|
||||
return sizeof(length) + length;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue