| 980 | */ |
| 981 | |
| 982 | int |
| 983 | xmlUTF8Strsize(const xmlChar *utf, int len) { |
| 984 | const xmlChar *ptr=utf; |
| 985 | int ch; |
| 986 | size_t ret; |
| 987 | |
| 988 | if (utf == NULL) |
| 989 | return(0); |
| 990 | |
| 991 | if (len <= 0) |
| 992 | return(0); |
| 993 | |
| 994 | while ( len-- > 0) { |
| 995 | if ( !*ptr ) |
| 996 | break; |
| 997 | if ( (ch = *ptr++) & 0x80) |
| 998 | while ((ch<<=1) & 0x80 ) { |
| 999 | if (*ptr == 0) break; |
| 1000 | ptr++; |
| 1001 | } |
| 1002 | } |
| 1003 | ret = ptr - utf; |
| 1004 | return (ret > INT_MAX ? 0 : ret); |
| 1005 | } |
| 1006 | |
| 1007 | |
| 1008 | /** |
no outgoing calls
no test coverage detected