src/stdlib/SDL_string.c
changeset 11049 6e24dc7c67c6
parent 10887 ccac10a548f9
child 11052 0666dea591ab
equal deleted inserted replaced
11048:0ebcca15e978 11049:6e24dc7c67c6
   505         }
   505         }
   506         SDL_memcpy(dst, src, bytes);
   506         SDL_memcpy(dst, src, bytes);
   507     }
   507     }
   508     dst[bytes] = '\0';
   508     dst[bytes] = '\0';
   509     return bytes;
   509     return bytes;
       
   510 }
       
   511 
       
   512 size_t
       
   513 SDL_utf8strlen(const char *str)
       
   514 {
       
   515     size_t retval = 0;
       
   516     const char *p = str;
       
   517     char ch;
       
   518 
       
   519     while ((ch = *(p++))) {
       
   520         /* if top two bits are 1 and 0, it's a continuation byte. */
       
   521         if ((ch & 0xc0) != 0x80) {
       
   522             retval++;
       
   523         }
       
   524     }
       
   525     
       
   526     return retval;
   510 }
   527 }
   511 
   528 
   512 size_t
   529 size_t
   513 SDL_strlcat(SDL_INOUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
   530 SDL_strlcat(SDL_INOUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
   514 {
   531 {