@@ -502,16 +502,16 @@ htmlNodeDumpFileFormat(FILE *out, xmlDocPtr doc,
502502 if (handler == NULL )
503503 htmlSaveErr (XML_SAVE_UNKNOWN_ENCODING , NULL , encoding );
504504 }
505+ } else {
506+ /*
507+ * Fallback to HTML or ASCII when the encoding is unspecified
508+ */
509+ if (handler == NULL )
510+ handler = xmlFindCharEncodingHandler ("HTML" );
511+ if (handler == NULL )
512+ handler = xmlFindCharEncodingHandler ("ascii" );
505513 }
506514
507- /*
508- * Fallback to HTML or ASCII when the encoding is unspecified
509- */
510- if (handler == NULL )
511- handler = xmlFindCharEncodingHandler ("HTML" );
512- if (handler == NULL )
513- handler = xmlFindCharEncodingHandler ("ascii" );
514-
515515 /*
516516 * save the content to a temp buffer.
517517 */
@@ -570,33 +570,22 @@ htmlDocDumpMemoryFormat(xmlDocPtr cur, xmlChar**mem, int *size, int format) {
570570 xmlCharEncoding enc ;
571571
572572 enc = xmlParseCharEncoding (encoding );
573- if (enc != cur -> charset ) {
574- if (cur -> charset != XML_CHAR_ENCODING_UTF8 ) {
575- /*
576- * Not supported yet
577- */
578- * mem = NULL ;
579- * size = 0 ;
580- return ;
581- }
582-
573+ if (enc != XML_CHAR_ENCODING_UTF8 ) {
583574 handler = xmlFindCharEncodingHandler (encoding );
584575 if (handler == NULL )
585576 htmlSaveErr (XML_SAVE_UNKNOWN_ENCODING , NULL , encoding );
586577
587- } else {
588- handler = xmlFindCharEncodingHandler (encoding );
589578 }
579+ } else {
580+ /*
581+ * Fallback to HTML or ASCII when the encoding is unspecified
582+ */
583+ if (handler == NULL )
584+ handler = xmlFindCharEncodingHandler ("HTML" );
585+ if (handler == NULL )
586+ handler = xmlFindCharEncodingHandler ("ascii" );
590587 }
591588
592- /*
593- * Fallback to HTML or ASCII when the encoding is unspecified
594- */
595- if (handler == NULL )
596- handler = xmlFindCharEncodingHandler ("HTML" );
597- if (handler == NULL )
598- handler = xmlFindCharEncodingHandler ("ascii" );
599-
600589 buf = xmlAllocOutputBufferInternal (handler );
601590 if (buf == NULL ) {
602591 * mem = NULL ;
@@ -1101,30 +1090,21 @@ htmlDocDump(FILE *f, xmlDocPtr cur) {
11011090 xmlCharEncoding enc ;
11021091
11031092 enc = xmlParseCharEncoding (encoding );
1104- if (enc != cur -> charset ) {
1105- if (cur -> charset != XML_CHAR_ENCODING_UTF8 ) {
1106- /*
1107- * Not supported yet
1108- */
1109- return (-1 );
1110- }
1111-
1093+ if (enc != XML_CHAR_ENCODING_UTF8 ) {
11121094 handler = xmlFindCharEncodingHandler (encoding );
11131095 if (handler == NULL )
11141096 htmlSaveErr (XML_SAVE_UNKNOWN_ENCODING , NULL , encoding );
1115- } else {
1116- handler = xmlFindCharEncodingHandler (encoding );
11171097 }
1098+ } else {
1099+ /*
1100+ * Fallback to HTML or ASCII when the encoding is unspecified
1101+ */
1102+ if (handler == NULL )
1103+ handler = xmlFindCharEncodingHandler ("HTML" );
1104+ if (handler == NULL )
1105+ handler = xmlFindCharEncodingHandler ("ascii" );
11181106 }
11191107
1120- /*
1121- * Fallback to HTML or ASCII when the encoding is unspecified
1122- */
1123- if (handler == NULL )
1124- handler = xmlFindCharEncodingHandler ("HTML" );
1125- if (handler == NULL )
1126- handler = xmlFindCharEncodingHandler ("ascii" );
1127-
11281108 buf = xmlOutputBufferCreateFile (f , handler );
11291109 if (buf == NULL ) return (-1 );
11301110 htmlDocContentDumpOutput (buf , cur , NULL );
@@ -1160,28 +1140,21 @@ htmlSaveFile(const char *filename, xmlDocPtr cur) {
11601140 xmlCharEncoding enc ;
11611141
11621142 enc = xmlParseCharEncoding (encoding );
1163- if (enc != cur -> charset ) {
1164- if (cur -> charset != XML_CHAR_ENCODING_UTF8 ) {
1165- /*
1166- * Not supported yet
1167- */
1168- return (-1 );
1169- }
1170-
1143+ if (enc != XML_CHAR_ENCODING_UTF8 ) {
11711144 handler = xmlFindCharEncodingHandler (encoding );
11721145 if (handler == NULL )
11731146 htmlSaveErr (XML_SAVE_UNKNOWN_ENCODING , NULL , encoding );
11741147 }
1148+ } else {
1149+ /*
1150+ * Fallback to HTML or ASCII when the encoding is unspecified
1151+ */
1152+ if (handler == NULL )
1153+ handler = xmlFindCharEncodingHandler ("HTML" );
1154+ if (handler == NULL )
1155+ handler = xmlFindCharEncodingHandler ("ascii" );
11751156 }
11761157
1177- /*
1178- * Fallback to HTML or ASCII when the encoding is unspecified
1179- */
1180- if (handler == NULL )
1181- handler = xmlFindCharEncodingHandler ("HTML" );
1182- if (handler == NULL )
1183- handler = xmlFindCharEncodingHandler ("ascii" );
1184-
11851158 /*
11861159 * save the content to a temp buffer.
11871160 */
@@ -1221,30 +1194,23 @@ htmlSaveFileFormat(const char *filename, xmlDocPtr cur,
12211194 xmlCharEncoding enc ;
12221195
12231196 enc = xmlParseCharEncoding (encoding );
1224- if (enc != cur -> charset ) {
1225- if (cur -> charset != XML_CHAR_ENCODING_UTF8 ) {
1226- /*
1227- * Not supported yet
1228- */
1229- return (-1 );
1230- }
1231-
1197+ if (enc != XML_CHAR_ENCODING_UTF8 ) {
12321198 handler = xmlFindCharEncodingHandler (encoding );
12331199 if (handler == NULL )
12341200 htmlSaveErr (XML_SAVE_UNKNOWN_ENCODING , NULL , encoding );
12351201 }
12361202 htmlSetMetaEncoding (cur , (const xmlChar * ) encoding );
12371203 } else {
12381204 htmlSetMetaEncoding (cur , (const xmlChar * ) "UTF-8" );
1239- }
12401205
1241- /*
1242- * Fallback to HTML or ASCII when the encoding is unspecified
1243- */
1244- if (handler == NULL )
1245- handler = xmlFindCharEncodingHandler ("HTML" );
1246- if (handler == NULL )
1247- handler = xmlFindCharEncodingHandler ("ascii" );
1206+ /*
1207+ * Fallback to HTML or ASCII when the encoding is unspecified
1208+ */
1209+ if (handler == NULL )
1210+ handler = xmlFindCharEncodingHandler ("HTML" );
1211+ if (handler == NULL )
1212+ handler = xmlFindCharEncodingHandler ("ascii" );
1213+ }
12481214
12491215 /*
12501216 * save the content to a temp buffer.
0 commit comments