diff options
author | Martin van Zijl <martin.vanzijl@gmail.com> | 2018-02-27 07:35:25 +1300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2018-11-13 14:03:18 +0100 |
commit | 607ab542d043c24bfbd6a08bb62fbebd095114e3 (patch) | |
tree | be432c064af7342c924046e3f375a57a2b5a6ba0 /sw/source/filter/ascii/wrtasc.cxx | |
parent | 4fdd85d0029a4d66b844a4e31c1ab1e041a2567a (diff) |
Fix tdf#44291. Allow saving text without byte-order mark.
Change-Id: Ib16a4f37adcb2cfb3d2af9b6af21a4b32e4ae54c
Reviewed-on: https://gerrit.libreoffice.org/50388
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sw/source/filter/ascii/wrtasc.cxx')
-rw-r--r-- | sw/source/filter/ascii/wrtasc.cxx | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/sw/source/filter/ascii/wrtasc.cxx b/sw/source/filter/ascii/wrtasc.cxx index b8964aaadd8b..c5f6f3fba971 100644 --- a/sw/source/filter/ascii/wrtasc.cxx +++ b/sw/source/filter/ascii/wrtasc.cxx @@ -85,6 +85,8 @@ SwASCWriter::~SwASCWriter() {} ErrCode SwASCWriter::WriteStream() { + bool bIncludeBOM = GetAsciiOptions().GetIncludeBOM(); + if( m_bASCII_ParaAsCR ) // If predefined m_sLineEnd = "\015"; else if( m_bASCII_ParaAsBlank ) @@ -154,15 +156,25 @@ ErrCode SwASCWriter::WriteStream() switch(GetAsciiOptions().GetCharSet()) { case RTL_TEXTENCODING_UTF8: - Strm().WriteUChar( 0xEF ).WriteUChar( 0xBB ).WriteUChar( 0xBF ); + if( bIncludeBOM ) + { + Strm().WriteUChar( 0xEF ).WriteUChar( 0xBB ).WriteUChar( 0xBF ); + } + break; case RTL_TEXTENCODING_UCS2: #ifdef OSL_LITENDIAN Strm().SetEndian(SvStreamEndian::LITTLE); - Strm().WriteUChar( 0xFF ).WriteUChar( 0xFE ); + if( bIncludeBOM ) + { + Strm().WriteUChar( 0xFF ).WriteUChar( 0xFE ); + } #else Strm().SetEndian(SvStreamEndian::BIG); - Strm().WriteUChar( 0xFE ).WriteUChar( 0xFF ); + if( bIncludeBOM ) + { + Strm().WriteUChar( 0xFE ).WriteUChar( 0xFF ); + } #endif break; |