FLTK logo

[master] 6361e7d - Fix for issue #247 : loading SVG image with BOM.

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] 6361e7d - Fix for issue #247 : loading SVG image with BOM. "ManoloFLTK" Jul 03, 2021  
 
commit 6361e7d1b794113c8b5869a76b6936daa47b0a06
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Sat Jul 3 18:07:44 2021 +0200
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Sat Jul 3 18:08:16 2021 +0200

    Fix for issue #247 : loading SVG image with BOM.

 src/fl_images_core.cxx | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git src/fl_images_core.cxx src/fl_images_core.cxx
index e5487d3..260e928 100644
--- src/fl_images_core.cxx
+++ src/fl_images_core.cxx
@@ -138,6 +138,12 @@ fl_check_images(const char *name,               // I - Filename
     }
   } // gzip'ed data
 # endif // HAVE_LIBZ
+  // check for presence of Byte Order Mark (BOM)
+  char utf8[4];
+  int lutf8 = fl_utf8encode(0xFEFF /* BOM in Unicode */, utf8);
+  if (memcmp(buf, utf8, lutf8) == 0) {
+    buf += lutf8; count -= lutf8;
+  }
 
   if ((count >= 5 && memcmp(buf, "<?xml", 5) == 0) ||
       (count >= 4 && memcmp(buf, "<svg", 4) == 0))
Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.