Project

General

Profile

Bug #1089 » 0002-strip_ucs_only_if_size_bigger_equals_two_v2.patch

patch_v2 - Felix Bolte, 29 May 2015 23:20

View differences:

src/tags.cpp (working copy)
2320 2320
        if (value.typeId() == unsignedByte && value.size() > 0) {
2321 2321
            DataBuf buf(value.size());
2322 2322
            value.copy(buf.pData_, invalidByteOrder);
2323
            // Strip trailing UCS-2 0-character, if there is one
2324
            if (buf.pData_[buf.size_ - 1] == 0 && buf.pData_[buf.size_ - 2] == 0)  buf.size_ -= 2;
2323
            // Strip trailing odd byte due to failing UCS-2 conversion
2324
            if (buf.size_ % 2 == 1)  buf.size_ -=1;
2325
            // Strip trailing UCS-2 0-characters, if there are some
2326
            while (buf.size_ >= 2) {
2327
                if (buf.pData_[buf.size_ - 1] == 0 && buf.pData_[buf.size_ - 2] == 0) {
2328
                    buf.size_ -= 2;
2329
                } else {
2330
                    break;
2331
                }
2332
            }
2325 2333
            std::string str((const char*)buf.pData_, buf.size_);
2326 2334
            cnv = convertStringCharset(str, "UCS-2LE", "UTF-8");
2327 2335
            if (cnv) os << str;
(2-2/2)