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

Function xmlParseCharEncoding

ThirdParty/libxml2/vtklibxml2/encoding.c:1096–1164  ·  view source on GitHub ↗

* xmlParseCharEncoding: * @name: the encoding name as parsed, in UTF-8 format (ASCII actually) * * Compare the string to the encoding schemes already known. Note * that the comparison is case insensitive accordingly to the section * [XML] 4.3.3 Character Encoding in Entities. * * Returns one of the XML_CHAR_ENCODING_... values or XML_CHAR_ENCODING_NONE * if not recognized. */

Source from the content-addressed store, hash-verified

1094 * if not recognized.
1095 */
1096xmlCharEncoding
1097xmlParseCharEncoding(const char* name)
1098{
1099 const char *alias;
1100 char upper[500];
1101 int i;
1102
1103 if (name == NULL)
1104 return(XML_CHAR_ENCODING_NONE);
1105
1106 /*
1107 * Do the alias resolution
1108 */
1109 alias = xmlGetEncodingAlias(name);
1110 if (alias != NULL)
1111 name = alias;
1112
1113 for (i = 0;i < 499;i++) {
1114 upper[i] = (char) toupper((unsigned char) name[i]);
1115 if (upper[i] == 0) break;
1116 }
1117 upper[i] = 0;
1118
1119 if (!strcmp(upper, "")) return(XML_CHAR_ENCODING_NONE);
1120 if (!strcmp(upper, "UTF-8")) return(XML_CHAR_ENCODING_UTF8);
1121 if (!strcmp(upper, "UTF8")) return(XML_CHAR_ENCODING_UTF8);
1122
1123 /*
1124 * NOTE: if we were able to parse this, the endianness of UTF16 is
1125 * already found and in use
1126 */
1127 if (!strcmp(upper, "UTF-16")) return(XML_CHAR_ENCODING_UTF16LE);
1128 if (!strcmp(upper, "UTF16")) return(XML_CHAR_ENCODING_UTF16LE);
1129
1130 if (!strcmp(upper, "ISO-10646-UCS-2")) return(XML_CHAR_ENCODING_UCS2);
1131 if (!strcmp(upper, "UCS-2")) return(XML_CHAR_ENCODING_UCS2);
1132 if (!strcmp(upper, "UCS2")) return(XML_CHAR_ENCODING_UCS2);
1133
1134 /*
1135 * NOTE: if we were able to parse this, the endianness of UCS4 is
1136 * already found and in use
1137 */
1138 if (!strcmp(upper, "ISO-10646-UCS-4")) return(XML_CHAR_ENCODING_UCS4LE);
1139 if (!strcmp(upper, "UCS-4")) return(XML_CHAR_ENCODING_UCS4LE);
1140 if (!strcmp(upper, "UCS4")) return(XML_CHAR_ENCODING_UCS4LE);
1141
1142
1143 if (!strcmp(upper, "ISO-8859-1")) return(XML_CHAR_ENCODING_8859_1);
1144 if (!strcmp(upper, "ISO-LATIN-1")) return(XML_CHAR_ENCODING_8859_1);
1145 if (!strcmp(upper, "ISO LATIN 1")) return(XML_CHAR_ENCODING_8859_1);
1146
1147 if (!strcmp(upper, "ISO-8859-2")) return(XML_CHAR_ENCODING_8859_2);
1148 if (!strcmp(upper, "ISO-LATIN-2")) return(XML_CHAR_ENCODING_8859_2);
1149 if (!strcmp(upper, "ISO LATIN 2")) return(XML_CHAR_ENCODING_8859_2);
1150
1151 if (!strcmp(upper, "ISO-8859-3")) return(XML_CHAR_ENCODING_8859_3);
1152 if (!strcmp(upper, "ISO-8859-4")) return(XML_CHAR_ENCODING_8859_4);
1153 if (!strcmp(upper, "ISO-8859-5")) return(XML_CHAR_ENCODING_8859_5);

Callers 2

xmlDocContentDumpOutputFunction · 0.85

Calls 2

xmlGetEncodingAliasFunction · 0.85
toupperFunction · 0.85

Tested by

no test coverage detected