| 1112 | */ |
| 1113 | |
| 1114 | xmlChar * |
| 1115 | xmlUTF8Strsub(const xmlChar *utf, int start, int len) { |
| 1116 | int i; |
| 1117 | int ch; |
| 1118 | |
| 1119 | if (utf == NULL) return(NULL); |
| 1120 | if (start < 0) return(NULL); |
| 1121 | if (len < 0) return(NULL); |
| 1122 | |
| 1123 | /* |
| 1124 | * Skip over any leading chars |
| 1125 | */ |
| 1126 | for (i = 0; i < start; i++) { |
| 1127 | ch = *utf++; |
| 1128 | if (ch == 0) |
| 1129 | return(NULL); |
| 1130 | /* skip over remaining bytes for this char */ |
| 1131 | if (ch & 0x80) { |
| 1132 | ch <<= 1; |
| 1133 | while (ch & 0x80) { |
| 1134 | if (*utf++ == 0) |
| 1135 | return(NULL); |
| 1136 | ch <<= 1; |
| 1137 | } |
| 1138 | } |
| 1139 | } |
| 1140 | |
| 1141 | return(xmlUTF8Strndup(utf, len)); |
| 1142 | } |
| 1143 | |
| 1144 | /** |
| 1145 | * xmlEscapeFormatString: |
no test coverage detected