Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
6.5.2
-
-
fc89bba57 (dev), e70faa7e0 (6.6)
Description
Moving from Qt5 to Qt6, QTextCodec::toUnicode() behavior is changed.
In Qt6 QTextCodec::codecForName("ISO 8859-1")->toUnicode("",0) returns
QString()
but it should return
QString(0, QChar(0))
Or in other words it should return of Data::allocate(0) instead of Data::sharedNull()
Attached example reproduces this. When run example output:
#Qt5.15: ###
input: "" isNull: no isEmpty: yes
input: "", 0 isNull: no <–(behavior) isEmpty: yes
input: nullptr isNull: yes isEmpty: yes
#Qt6.5.2: ###
input: "" isNull: no isEmpty: yes
input: "", 0 isNull: yes <–(different behavior)isEmpty: yes
input: nullptr isNull: yes isEmpty: yes
Expectation is, toUnicode("") and toUnicode("",0) should return the same value and an empty string should stay an empty string no matter which coding is used.
Update:
probably fix also needed in qtextcodec.h
QString toUnicode(const char *in, int length, ConverterState *state = nullptr) const { if (in == nullptr || length <= 0) return {}; return convertToUnicode(in, length, state); } QByteArray fromUnicode(const QChar *in, int length, ConverterState *state = nullptr) const { if (in == nullptr || length <= 0) return {}; return convertFromUnicode(in, length, state); }
"|| length <= 0" may be removed.