/[public]/psiconv/trunk/program/psiconv/general.c
ViewVC logotype

Diff of /psiconv/trunk/program/psiconv/general.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 189 Revision 351
1/* 1/*
2 general.c - Part of psiconv, a PSION 5 file formats converter 2 general.c - Part of psiconv, a PSION 5 file formats converter
3 Copyright (c) 2003 Frodo Looijaard <frodol@dds.nl> 3 Copyright (c) 2003-2014 Frodo Looijaard <frodo@frodo.looijaard.name>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
31/* Output a UCS2 character in one of the supported encodings. */ 31/* Output a UCS2 character in one of the supported encodings. */
32void output_char(psiconv_config config, psiconv_list list, 32void output_char(psiconv_config config, psiconv_list list,
33 psiconv_ucs2 character, encoding enc) 33 psiconv_ucs2 character, encoding enc)
34{ 34{
35 psiconv_u8 temp; 35 psiconv_u8 temp;
36 psiconv_u8 *byteptr;
36 int res; 37 int res,i;
38 psiconv_buffer buf;
39#define TEMPSTR_LEN 80
40 char tempstr[TEMPSTR_LEN];
37 41
38 if (enc == ENCODING_UCS2) { 42 if (enc == ENCODING_UCS2) {
39 temp = character >> 8; 43 temp = character >> 8;
40 if ((res = psiconv_list_add(list,&temp))) { 44 if ((res = psiconv_list_add(list,&temp))) {
41 fputs("Out of memory error\n",stderr); 45 fputs("Out of memory error\n",stderr);
90 temp = character; 94 temp = character;
91 if ((res = psiconv_list_add(list,&temp))) { 95 if ((res = psiconv_list_add(list,&temp))) {
92 fputs("Out of memory error\n",stderr); 96 fputs("Out of memory error\n",stderr);
93 exit(1); 97 exit(1);
94 } 98 }
95 } else if (enc == ENCODING_PSION) { 99 } else if (enc == ENCODING_ASCII_HTML) {
96 temp = psiconv_unicode_to_char(config,character); 100 if (character >= 0x80) {
101 snprintf(tempstr,TEMPSTR_LEN,"&#x%x;",character);
102 output_simple_chars(config,list,tempstr,enc);
103 } else {
104 temp = character;
97 if ((res = psiconv_list_add(list,&temp))) { 105 if ((res = psiconv_list_add(list,&temp))) {
98 fputs("Out of memory error\n",stderr); 106 fputs("Out of memory error\n",stderr);
99 exit(1); 107 exit(1);
100 } 108 }
109 }
110 } else if (enc == ENCODING_PSION) {
111 if (!(buf = psiconv_buffer_new())) {
112 fputs("Out of memory error\n",stderr);
113 exit(1);
114 }
115 psiconv_unicode_write_char(config,buf,0,character);
116 for (i = 0; i < psiconv_buffer_length(buf); i++) {
117 if (!(byteptr = psiconv_buffer_get(buf,i))) {
118 fputs("Internal memory corruption\n",stderr);
119 exit(1);
120 }
121 if ((res = psiconv_list_add(list,byteptr))) {
122 fputs("Out of memory error\n",stderr);
123 exit(1);
124 }
125 }
126 psiconv_buffer_free(buf);
101 } 127 }
102} 128}
103 129
104void output_string(psiconv_config config, psiconv_list list, 130void output_string(psiconv_config config, psiconv_list list,
105 psiconv_ucs2 *string, encoding enc) 131 psiconv_ucs2 *string, encoding enc)

Legend:
Removed from v.189  
changed lines
  Added in v.351

frodo@frodo.looijaard.name
ViewVC Help
Powered by ViewVC 1.1.26