1 | /* |
1 | /* |
2 | parse_aux.c - Part of psiconv, a PSION 5 file formats converter |
2 | parse_aux.c - Part of psiconv, a PSION 5 file formats converter |
3 | Copyright (c) 1999, 2000 Frodo Looijaard <frodol@dds.nl> |
3 | Copyright (c) 1999-2005 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 | |
31 | |
32 | |
32 | |
33 | char *psiconv_make_printable(const psiconv_config config, |
33 | char *psiconv_make_printable(const psiconv_config config, |
34 | const psiconv_string_t input) |
34 | const psiconv_string_t input) |
35 | { |
35 | { |
36 | int i,len; |
36 | int i; |
37 | psiconv_u8 *intermed; |
|
|
38 | char *output; |
37 | char *output; |
39 | int res; |
|
|
40 | |
38 | |
41 | if ((res = psiconv_unicode_to_chars(config,input,&intermed))) |
|
|
42 | return NULL; |
|
|
43 | |
|
|
44 | len = 0; |
|
|
45 | while (intermed[len]) |
|
|
46 | len++; |
|
|
47 | |
|
|
48 | if (!(output = malloc(sizeof(*output) * (len + 1)))) { |
39 | if (!(output = malloc(sizeof(*output) * |
49 | free(intermed); |
40 | (psiconv_unicode_strlen(input) + 1)))) { |
50 | return NULL; |
41 | return NULL; |
51 | } |
42 | } |
52 | |
43 | |
53 | for (i = 0; i < len; i ++) |
44 | for (i = 0; i < psiconv_unicode_strlen(input); i ++) |
54 | if (intermed[i] < 0x20 || intermed[i] >= 0x7f) |
45 | if (input[i] < 0x20 || input[i] >= 0x7f) |
55 | output[i] = '.'; |
46 | output[i] = '.'; |
56 | else |
47 | else |
57 | output[i] = intermed[i]; |
48 | output[i] = input[i]; |
58 | output[i] = 0; |
49 | output[i] = 0; |
59 | free(intermed); |
|
|
60 | return output; |
50 | return output; |
61 | } |
51 | } |