* xmlOpenCharEncodingHandler: * @name: a string describing the char encoding. * @output: boolean, use handler for output * @out: pointer to result * * Find or create a handler matching the encoding. If no default or * registered handler could be found, try to create a handler using * iconv or ICU if supported. * * The handler must be closed with xmlCharEncCloseFunc. * * If the encodi
| 1932 | * Returns an xmlParserErrors error code. |
| 1933 | */ |
| 1934 | int |
| 1935 | xmlOpenCharEncodingHandler(const char *name, int output, |
| 1936 | xmlCharEncodingHandler **out) { |
| 1937 | const char *nalias; |
| 1938 | const char *norig; |
| 1939 | xmlCharEncoding enc; |
| 1940 | int ret; |
| 1941 | |
| 1942 | if (out == NULL) |
| 1943 | return(XML_ERR_ARGUMENT); |
| 1944 | *out = NULL; |
| 1945 | |
| 1946 | if (name == NULL) |
| 1947 | return(XML_ERR_ARGUMENT); |
| 1948 | |
| 1949 | if ((xmlStrcasecmp(BAD_CAST name, BAD_CAST "UTF-8") == 0) || |
| 1950 | (xmlStrcasecmp(BAD_CAST name, BAD_CAST "UTF8") == 0)) |
| 1951 | return(XML_ERR_OK); |
| 1952 | |
| 1953 | /* |
| 1954 | * Do the alias resolution |
| 1955 | */ |
| 1956 | norig = name; |
| 1957 | nalias = xmlGetEncodingAlias(name); |
| 1958 | if (nalias != NULL) |
| 1959 | name = nalias; |
| 1960 | |
| 1961 | ret = xmlFindHandler(name, output, out); |
| 1962 | if (*out != NULL) |
| 1963 | return(0); |
| 1964 | if (ret != XML_ERR_UNSUPPORTED_ENCODING) |
| 1965 | return(ret); |
| 1966 | |
| 1967 | /* |
| 1968 | * Fallback using the canonical names |
| 1969 | * |
| 1970 | * TODO: We should make sure that the name of the returned |
| 1971 | * handler equals norig. |
| 1972 | */ |
| 1973 | enc = xmlParseCharEncoding(norig); |
| 1974 | return(xmlLookupCharEncodingHandler(enc, out)); |
| 1975 | } |
| 1976 | |
| 1977 | /** |
| 1978 | * xmlFindCharEncodingHandler: |
no test coverage detected