* xmlUTF8Strpos: * @utf: the input UTF8 * * @pos: the position of the desired UTF8 char (in chars) * * a function to provide the equivalent of fetching a * character from a string array * * Returns a pointer to the UTF8 character or NULL */
| 1041 | * Returns a pointer to the UTF8 character or NULL |
| 1042 | */ |
| 1043 | const xmlChar * |
| 1044 | xmlUTF8Strpos(const xmlChar *utf, int pos) { |
| 1045 | int ch; |
| 1046 | |
| 1047 | if (utf == NULL) return(NULL); |
| 1048 | if (pos < 0) |
| 1049 | return(NULL); |
| 1050 | while (pos--) { |
| 1051 | if ((ch=*utf++) == 0) return(NULL); |
| 1052 | if ( ch & 0x80 ) { |
| 1053 | /* if not simple ascii, verify proper format */ |
| 1054 | if ( (ch & 0xc0) != 0xc0 ) |
| 1055 | return(NULL); |
| 1056 | /* then skip over remaining bytes for this char */ |
| 1057 | while ( (ch <<= 1) & 0x80 ) |
| 1058 | if ( (*utf++ & 0xc0) != 0x80 ) |
| 1059 | return(NULL); |
| 1060 | } |
| 1061 | } |
| 1062 | return((xmlChar *)utf); |
| 1063 | } |
| 1064 | |
| 1065 | /** |
| 1066 | * xmlUTF8Strloc: |
no outgoing calls
no test coverage detected