* xmlSwitchEncodingName: * @ctxt: the parser context, only for error reporting * @input: the input strea, * @encoding: the encoding name * * Available since 2.13.0. * * Returns 0 in case of success, -1 otherwise */
| 1107 | * Returns 0 in case of success, -1 otherwise |
| 1108 | */ |
| 1109 | static int |
| 1110 | xmlSwitchInputEncodingName(xmlParserCtxtPtr ctxt, xmlParserInputPtr input, |
| 1111 | const char *encoding) { |
| 1112 | xmlCharEncodingHandlerPtr handler; |
| 1113 | int res; |
| 1114 | |
| 1115 | if (encoding == NULL) |
| 1116 | return(-1); |
| 1117 | |
| 1118 | res = xmlOpenCharEncodingHandler(encoding, /* output */ 0, &handler); |
| 1119 | if (res == XML_ERR_UNSUPPORTED_ENCODING) { |
| 1120 | xmlWarningMsg(ctxt, XML_ERR_UNSUPPORTED_ENCODING, |
| 1121 | "Unsupported encoding: %s\n", BAD_CAST encoding, NULL); |
| 1122 | return(-1); |
| 1123 | } else if (res != XML_ERR_OK) { |
| 1124 | xmlFatalErr(ctxt, res, encoding); |
| 1125 | return(-1); |
| 1126 | } |
| 1127 | |
| 1128 | return(xmlSwitchInputEncoding(ctxt, input, handler)); |
| 1129 | } |
| 1130 | |
| 1131 | /** |
| 1132 | * xmlSwitchEncodingName: |
no test coverage detected