void TY_(ReportEncodingError)(TidyDocImpl* doc, uint code, uint c, Bool discarded) { char buf[ 32 ] = {'\0'}; ctmbstr action = tidyLocalizedString(discarded ? STRING_DISCARDING : STRING_REPLACING); ctmbstr fmt = tidyLocalizedString(code); /* An encoding mismatch is currently treated as a non-fatal error */ switch (code) { case VENDOR_SPECIFIC_CHARS: NtoS(c, buf); doc->badChars |= BC_VENDOR_SPECIFIC_CHARS; break; case INVALID_SGML_CHARS: NtoS(c, buf); doc->badChars |= BC_INVALID_SGML_CHARS; break; case INVALID_UTF8: TY_(tmbsnprintf)(buf, sizeof(buf), "U+%04X", c); doc->badChars |= BC_INVALID_UTF8; break; #if SUPPORT_UTF16_ENCODINGS case INVALID_UTF16: TY_(tmbsnprintf)(buf, sizeof(buf), "U+%04X", c); doc->badChars |= BC_INVALID_UTF16; break; #endif case INVALID_NCR: NtoS(c, buf); doc->badChars |= BC_INVALID_NCR; break; } if (fmt) messageLexer( doc, TidyWarning, code, fmt, action, buf ); }
void ReportEncodingError(Lexer *lexer, uint code, uint c) { char buf[32]; lexer->warnings++; if (ShowWarnings) { ReportPosition(lexer); if (code == WINDOWS_CHARS) { NtoS(c, buf); lexer->badChars |= WINDOWS_CHARS; tidy_out(lexer->errout, "Warning: replacing illegal character code %s", buf); } tidy_out(lexer->errout, "\n"); } }