[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - svtools/source

David Tardon dtardon at redhat.com
Tue Aug 12 01:25:24 PDT 2014


 svtools/source/svrtf/svparser.cxx |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

New commits:
commit 26a0f8b04f7d5ba8ee7e5f68e8379d152b03a2c7
Author: David Tardon <dtardon at redhat.com>
Date:   Thu Jul 10 16:14:08 2014 +0200

    fdo#81044 detect UTF-8 BOM too
    
    Change-Id: I6fd041780b889e2125b916964ba27d032667dcd6
    Reviewed-on: https://gerrit.libreoffice.org/10742
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/svtools/source/svrtf/svparser.cxx b/svtools/source/svrtf/svparser.cxx
index 114e377..d55f6f0 100644
--- a/svtools/source/svrtf/svparser.cxx
+++ b/svtools/source/svrtf/svparser.cxx
@@ -185,6 +185,25 @@ sal_Unicode SvParser::GetNextChar()
                     }
                 }
             }
+            else if( 0xef == c1 || 0xbb == c1 ) // check for UTF-8 BOM
+            {
+                rInput.ReadUChar( c2 );
+                bErr = rInput.IsEof() || rInput.GetError();
+                if( !bErr )
+                {
+                    if( ( 0xef == c1 && 0xbb == c2 ) || ( 0xbb == c1 && 0xef == c2 ) )
+                    {
+                        unsigned char c3(0);
+                        rInput.ReadUChar( c3 );
+                        bErr = rInput.IsEof() || rInput.GetError();
+                        if( !bErr && ( 0xbf == c3 ) )
+                        {
+                            eSrcEnc = RTL_TEXTENCODING_UTF8;
+                            bSeekBack = false;
+                        }
+                    }
+                }
+            }
         }
         if( bSeekBack )
             rInput.Seek( 0 );


More information about the Libreoffice-commits mailing list