FLTK logo

[fltk.coredev] Re: RFC: Small mod to fl_utf8len() to detect invalid single char UTF-8 bytes

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

Re: RFC: Small mod to fl_utf8len() to detect invalid single char UTF-8 bytes imacarthur 08:08 Aug 12  
 
On Wednesday, 12 August 2026 at 04:35:58 UTC+1 Greg wrote:
Suggesting this one line change to fl_utf8len() to detect the two invalid
single character UTF-8 chars 0xFE and 0xFF:
@@ -107,6 +107,7 @@ int fl_utf8len(char c)
       if (c & 0x10) {
         if (c & 0x08) {
           if (c & 0x04) {
+            if (c & 0x02) return -1;
             return 6;
           }
           return 5;

Looks plausible to me, FWIW.
Though my OCD would probably code it as  

                           if (c & 0x02) { return -1; }

Because "goto FAIL;" etc...


--
You received this message because you are subscribed to the Google Groups "fltk.coredev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkcoredev+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/fltkcoredev/1605ea6b-b4cb-4785-a58d-9b2af1ed707cn%40googlegroups.com.
[ Direct Link to Message ]
 
     
[ Previous Message ] [ New Message | Reply ] [ Next Message ]
 
 

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