basctl/source/basicide/baside2.cxx |   15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

New commits:
commit c356e5e0530e609a2ae9e8b11fb3c4ed43f966d4
Author:     Andreas Heinisch <andreas.heini...@yahoo.de>
AuthorDate: Tue Aug 31 19:59:35 2021 +0200
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Wed Sep 1 14:08:41 2021 +0200

    tdf#139196 - Remove local BOM logic
    
    Change-Id: Ic14d8556ab0f39b6f10619d714e1d8c5ba6c22d9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121392
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/basctl/source/basicide/baside2.cxx 
b/basctl/source/basicide/baside2.cxx
index 4e562420ef19..ff14bd6ccdc2 100644
--- a/basctl/source/basicide/baside2.cxx
+++ b/basctl/source/basicide/baside2.cxx
@@ -190,17 +190,6 @@ void lcl_ConvertTabsToSpaces( OUString& rLine )
     rLine = aResult.makeStringAndClear();
 }
 
-void DetectUTF8BOMCharset(SvStream& pStream)
-{
-    sal_uInt8 pBuf[3];
-    sal_Int32 nRead = pStream.ReadBytes(pBuf, 3);
-    unsigned char const BOM[3] = { 0xEF, 0xBB, 0xBF };
-    if (nRead == 3 && memcmp(pBuf, BOM, 3) == 0)
-        pStream.SetStreamCharSet(RTL_TEXTENCODING_UTF8);
-    else
-        pStream.Seek(0);
-}
-
 } // namespace
 
 ModulWindow::ModulWindow (ModulWindowLayout* pParent, ScriptDocument const& 
rDocument,
@@ -447,7 +436,9 @@ void ModulWindow::LoadBasic()
         GetEditorWindow().CreateProgress( IDEResId(RID_STR_GENERATESOURCE), 
nLines*4 );
         GetEditEngine()->SetUpdateMode( false );
         // tdf#139196 - import macros using either default or utf-8 text 
encoding
-        DetectUTF8BOMCharset(*pStream);
+        pStream->StartReadingUnicodeText(RTL_TEXTENCODING_UTF8);
+        if (pStream->Tell() == 3)
+            pStream->SetStreamCharSet(RTL_TEXTENCODING_UTF8);
         GetEditView()->Read( *pStream );
         GetEditEngine()->SetUpdateMode( true );
         GetEditorWindow().PaintImmediately();

Reply via email to