diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2022-10-18 15:00:02 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2022-10-22 09:32:54 +0200 |
commit | e7be4bb5a3a388e844b718fa843c7a66b5c286d1 (patch) | |
tree | 08873538211f3cd9f0526c6527cb44c337ba88a9 /tools/source | |
parent | 8cbc179acedb1fdb07ccafbd60a271acad90a3bc (diff) |
Fix StartWritingUnicodeText
Its comment in include/tools/stream.hxx tells:
Switch to no endian swapping and write 0xfeff
It was introduced in commit 3c2105e07d29b2069349e1a54e08463d359f988f
Author Eike Rathke <er@openoffice.org>
Date Fri Dec 22 00:19:05 2000 +0000
new: read/write Unicode or Bytecode
and included a call to SetEndianSwap( FALSE ). That call was dropped
in commit 8130714148d58dd2bf1ef12dcc6dd6d5838be0d1
Author Noel Grandin <noel@peralex.com>
Date Mon Jan 05 08:47:31 2015 +0200
fdo#84938: replace NUMBERFORMAT_INT_ constants with 'enum class'
(likely by accident).
To simplify the fix, drop redundant m_nEndian: m_isSwap is enough.
Change-Id: Ia9a0fe2d55563e7ba21bd4cf17c4ca999c6feaf7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141521
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'tools/source')
-rw-r--r-- | tools/source/stream/stream.cxx | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx index f2aed5da6174..f6d703423828 100644 --- a/tools/source/stream/stream.cxx +++ b/tools/source/stream/stream.cxx @@ -361,11 +361,19 @@ void SvStream::SetError( ErrCode nErrorCode ) void SvStream::SetEndian( SvStreamEndian nNewFormat ) { - m_nEndian = nNewFormat; #ifdef OSL_BIGENDIAN - m_isSwap = m_nEndian == SvStreamEndian::LITTLE; + m_isSwap = nNewFormat == SvStreamEndian::LITTLE; #else - m_isSwap = m_nEndian == SvStreamEndian::BIG; + m_isSwap = nNewFormat == SvStreamEndian::BIG; +#endif +} + +SvStreamEndian SvStream::GetEndian() const +{ +#ifdef OSL_BIGENDIAN + return m_isSwap ? SvStreamEndian::LITTLE : SvStreamEndian::BIG; +#else + return m_isSwap ? SvStreamEndian::BIG : SvStreamEndian::LITTLE; #endif } @@ -709,10 +717,11 @@ bool SvStream::WriteUniOrByteChar( sal_Unicode ch, rtl_TextEncoding eDestCharSet void SvStream::StartWritingUnicodeText() { + m_isSwap = false; // Switch to no endian swapping // BOM, Byte Order Mark, U+FEFF, see // http://www.unicode.org/faq/utf_bom.html#BOM // Upon read: 0xfeff(-257) => no swap; 0xfffe(-2) => swap - writeNumberWithoutSwap(sal_uInt16(0xfeff)); // write native format + WriteUInt16(0xfeff); } void SvStream::StartReadingUnicodeText( rtl_TextEncoding eReadBomCharSet ) |