From 1fa5bb85533355119c0c5396dccbdfa9e18f60f6 Mon Sep 17 00:00:00 2001 From: TangoCash Date: Sat, 27 Oct 2018 18:06:37 +0200 Subject: [PATCH] fix xml utf8 detection Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/08b8505da6225f7006d4bf792f0fc2988670393b Author: TangoCash Date: 2018-10-27 (Sat, 27 Oct 2018) --- lib/xmltree/xmlinterface.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/xmltree/xmlinterface.cpp b/lib/xmltree/xmlinterface.cpp index 5cb64bc09..a63903d29 100644 --- a/lib/xmltree/xmlinterface.cpp +++ b/lib/xmltree/xmlinterface.cpp @@ -270,6 +270,10 @@ xmlDocPtr parseXmlFile(const char * filename, bool,const char* encoding) { enc = pugi::encoding_latin1; } + else if ((line[0] == 0xef) && (line[1] == 0xbb) && (line[2] == 0xbf)) + { + enc = pugi::encoding_utf8; + } in.close(); } } @@ -307,6 +311,11 @@ xmlDocPtr parseXmlFile(const char * filename, bool,const char* encoding) size_t read_size = gzread(xmlgz_file,buffer,gzsize); + char utf8[3]; + strncpy(utf8,(char *)buffer,3); + if ((utf8[0] == 0xef) && (utf8[1] == 0xbb) && (utf8[2] == 0xbf)) + enc = pugi::encoding_utf8; + if (read_size != gzsize) { gzclose(xmlgz_file);