Mirror of :pserver:cvs@cvs.fefe.de:/cvs libowfat https://www.fefe.de/libowfat/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

22 lines
465 B

  1. #include "scan.h"
  2. size_t scan_utf8_sem(const char* in,size_t len,uint32_t* num) {
  3. size_t r=scan_utf8(in,len,num);
  4. if (r>0) {
  5. if (*num>=0xd800 && *num<=0xdfff) return 0;
  6. if ((*num&0xfffe)==0xfffe) return 0;
  7. if (*num>=0xfdd0 && *num<=0xfdef) return 0;
  8. }
  9. return r;
  10. }
  11. #ifdef UNITTEST
  12. #include <assert.h>
  13. int main() {
  14. /* rest of scan_utf8 tested in scan_utf8.c unit tests */
  15. assert(scan_utf8_sem("\xed\xa0\x80",4,&l)==0);
  16. return 0;
  17. }
  18. #endif