| 365 | */ |
| 366 | |
| 367 | static int |
| 368 | htmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) { |
| 369 | const unsigned char *cur; |
| 370 | unsigned char c; |
| 371 | unsigned int val; |
| 372 | |
| 373 | if (ctxt->input->end - ctxt->input->cur < INPUT_CHUNK) |
| 374 | xmlParserGrow(ctxt); |
| 375 | |
| 376 | if ((ctxt->input->flags & XML_INPUT_HAS_ENCODING) == 0) { |
| 377 | xmlChar * guess; |
| 378 | |
| 379 | /* |
| 380 | * Assume it's a fixed length encoding (1) with |
| 381 | * a compatible encoding for the ASCII set, since |
| 382 | * HTML constructs only use < 128 chars |
| 383 | */ |
| 384 | if (*ctxt->input->cur < 0x80) { |
| 385 | if (*ctxt->input->cur == 0) { |
| 386 | if (ctxt->input->cur < ctxt->input->end) { |
| 387 | htmlParseErrInt(ctxt, XML_ERR_INVALID_CHAR, |
| 388 | "Char 0x%X out of allowed range\n", 0); |
| 389 | *len = 1; |
| 390 | return(' '); |
| 391 | } else { |
| 392 | *len = 0; |
| 393 | return(0); |
| 394 | } |
| 395 | } |
| 396 | *len = 1; |
| 397 | return(*ctxt->input->cur); |
| 398 | } |
| 399 | |
| 400 | /* |
| 401 | * Humm this is bad, do an automatic flow conversion |
| 402 | */ |
| 403 | guess = htmlFindEncoding(ctxt); |
| 404 | if (guess == NULL) { |
| 405 | xmlSwitchEncoding(ctxt, XML_CHAR_ENCODING_8859_1); |
| 406 | } else { |
| 407 | xmlSwitchEncodingName(ctxt, (const char *) guess); |
| 408 | xmlFree(guess); |
| 409 | } |
| 410 | ctxt->input->flags |= XML_INPUT_HAS_ENCODING; |
| 411 | } |
| 412 | |
| 413 | /* |
| 414 | * We are supposed to handle UTF8, check it's valid |
| 415 | * From rfc2044: encoding of the Unicode values on UTF-8: |
| 416 | * |
| 417 | * UCS-4 range (hex.) UTF-8 octet sequence (binary) |
| 418 | * 0000 0000-0000 007F 0xxxxxxx |
| 419 | * 0000 0080-0000 07FF 110xxxxx 10xxxxxx |
| 420 | * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx |
| 421 | * |
| 422 | * Check for the 0x110000 limit too |
| 423 | */ |
| 424 | cur = ctxt->input->cur; |
nothing calls this directly
no test coverage detected