MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlSwitchEncoding

Function xmlSwitchEncoding

ThirdParty/libxml2/vtklibxml2/parserInternals.c:1059–1097  ·  view source on GitHub ↗

* xmlSwitchEncoding: * @ctxt: the parser context * @enc: the encoding value (number) * * Use encoding specified by enum to decode input data. This overrides * the encoding found in the XML declaration. * * This function can also be used to override the encoding of chunks * passed to xmlParseChunk. * * Returns 0 in case of success, -1 otherwise */

Source from the content-addressed store, hash-verified

1057 * Returns 0 in case of success, -1 otherwise
1058 */
1059int
1060xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc)
1061{
1062 xmlCharEncodingHandlerPtr handler = NULL;
1063 int ret;
1064 int res;
1065
1066 if ((ctxt == NULL) || (ctxt->input == NULL))
1067 return(-1);
1068
1069 switch (enc) {
1070 case XML_CHAR_ENCODING_NONE:
1071 case XML_CHAR_ENCODING_UTF8:
1072 case XML_CHAR_ENCODING_ASCII:
1073 res = 0;
1074 break;
1075 case XML_CHAR_ENCODING_EBCDIC:
1076 res = xmlDetectEBCDIC(ctxt->input, &handler);
1077 break;
1078 default:
1079 res = xmlLookupCharEncodingHandler(enc, &handler);
1080 break;
1081 }
1082
1083 if (res != 0) {
1084 const char *name = xmlGetCharEncodingName(enc);
1085
1086 xmlFatalErr(ctxt, res, (name ? name : "<null>"));
1087 return(-1);
1088 }
1089
1090 ret = xmlSwitchInputEncoding(ctxt, ctxt->input, handler);
1091
1092 if ((ret >= 0) && (enc == XML_CHAR_ENCODING_NONE)) {
1093 ctxt->input->flags &= ~XML_INPUT_HAS_ENCODING;
1094 }
1095
1096 return(ret);
1097}
1098
1099/**
1100 * xmlSwitchEncodingName:

Callers 5

htmlCurrentCharFunction · 0.85
htmlParseDocumentFunction · 0.85
htmlParseTryOrFinishFunction · 0.85
xmlDetectEncodingFunction · 0.85
xmlIOParseDTDFunction · 0.85

Calls 5

xmlDetectEBCDICFunction · 0.85
xmlGetCharEncodingNameFunction · 0.85
xmlFatalErrFunction · 0.85
xmlSwitchInputEncodingFunction · 0.85

Tested by

no test coverage detected