QTextCodec: use DefaultConversion too
Complements dd0ddad631170e8825ea549eedc14c89712b0c1b and makes
QTextCodec::{to,from}Unicode also use the flag. Same reasoning as that
commit.
The changes to the tests are to make it compatible with what QTextCodec
did in Qt 5: the stateless fromUnicode() conversion did add BOMs, so we
match Qt 5's behavior here. That includes conversions of empty strings,
which QStringView() on a null pointer is.
In fact, I think commit 3695cd090b7f490e941fa837b49f926514a82ddd is
wrong in returning an empty QByteArray(). It went in because:
a) the BOM behavior was different until the fix in this commit and in
commit dd0ddad631170e8825ea549eedc14c89712b0c1b
b) the test was not backported to Qt 5, which would have identified the
difference in behavior
I'm not fixing that difference in behavior because there's no Qt 5 code
to be compatible with, as Qt 5 crashed when attempting to convert null
pointers. The behavior of converting an empty QStringView() remains the
same (just no longer tested).
[ChangeLog][Qt5CoreCompat][QTextCodec] Fixed a bug that caused
QTextCodec not to write the Byte Order Mark for UTF codecs. QTextCodec
now has the same behavior as Qt 5.x.
Task-number: QTBUG-122795
Pick-to: 6.5 6.7 6.8
Change-Id: If05cb740b64f42eba21efffd17d13d0145f74945
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>