FLTK logo

Re: [fltk.coredev] 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 Greg Ercolano 17:59 Aug 12  
 
    I should mention though; FWIW, codex initially suggested rewriting the code to be as follows, as per RFC 3629:
  int fl_utf8len(char c) {
    const unsigned char u = (unsigned char)c;
    if (u <= 0x7f) return 1;
    if (u >= 0xc2 && u <= 0xdf) return 2;
    if (u >= 0xe0 && u <= 0xef) return 3;
    if (u >= 0xf0 && u <= 0xf4) return 4;
    return -1;
  }

  int fl_utf8len1(char c) {
    const int len = fl_utf8len(c);
    return len < 0 ? 1 : len;
  }
[..]
[..]
    OK, great, I'll commit it today, as it would seriously help the terminal tests.
    We can always revert if other devs makes a compelling argument to the contrary.


    I've opened up issue # 1576 for this, and will associate the commit with that issue, so there can be a chance for comments and digressions.

    Due to the increased chances of invalid return values of -1, I asked codex to check all of FLTK code to look for possible mishandling of the -1 return from fl_utf8len(), and it did find at least one case in Fl_Input_::expandpos(), so solving that and whatever else can be connected to that issue.

--
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/20fd7d47-6ef0-425b-a156-32a6fde5bee8%40seriss.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'.