--- psiconv/trunk/program/psiconv/general.c 2004/01/26 14:00:40 189 +++ psiconv/trunk/program/psiconv/general.c 2004/02/22 22:24:39 217 @@ -1,6 +1,6 @@ /* general.c - Part of psiconv, a PSION 5 file formats converter - Copyright (c) 2003 Frodo Looijaard + Copyright (c) 2003-2004 Frodo Looijaard This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -33,7 +33,11 @@ psiconv_ucs2 character, encoding enc) { psiconv_u8 temp; - int res; + psiconv_u8 *byteptr; + int res,i; + psiconv_buffer buf; +#define TEMPSTR_LEN 80 + char tempstr[TEMPSTR_LEN]; if (enc == ENCODING_UCS2) { temp = character >> 8; @@ -92,12 +96,34 @@ fputs("Out of memory error\n",stderr); exit(1); } + } else if (enc == ENCODING_ASCII_HTML) { + if (character >= 0x80) { + snprintf(tempstr,TEMPSTR_LEN,"&#x%x;",character); + output_simple_chars(config,list,tempstr,enc); + } else { + temp = character; + if ((res = psiconv_list_add(list,&temp))) { + fputs("Out of memory error\n",stderr); + exit(1); + } + } } else if (enc == ENCODING_PSION) { - temp = psiconv_unicode_to_char(config,character); - if ((res = psiconv_list_add(list,&temp))) { + if (!(buf = psiconv_buffer_new())) { + fputs("Out of memory error\n",stderr); + exit(1); + } + psiconv_unicode_write_char(config,buf,0,character); + for (i = 0; i < psiconv_buffer_length(buf); i++) { + if (!(byteptr = psiconv_buffer_get(buf,i))) { + fputs("Internal memory corruption\n",stderr); + exit(1); + } + if ((res = psiconv_list_add(list,byteptr))) { fputs("Out of memory error\n",stderr); exit(1); } + } + psiconv_buffer_free(buf); } }