--- psiconv/trunk/program/psiconv/psiconv.c 2002/01/29 20:15:23 146 +++ psiconv/trunk/program/psiconv/psiconv.c 2002/05/10 15:55:55 147 @@ -17,6 +17,22 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +/* + 2002/Apr. Keita KAWABE + * Support for narrow build Asian Psions added. + + Now psiconv understands -u or --UTF8 option. + This option is passed to output_function as the fourth parameter + (thus the typedef of output_function was changed). + + If a called generator (gen_*.c) can handle UTF8, then it handles + the character conversion etc. accordingly. + + * psiconv seemed to want to take the argument of the options + case-insensitively (i.e. LaTeX -> LATEX), but that was not working + under my environment. Fixed it. +*/ + /* Driver program */ #include "config.h" @@ -51,7 +67,7 @@ int i,j; puts("Syntax: psiconv [OPTIONS..] [FILE]"); - puts("Convert the psion Word file FILE to a HTML file"); + puts("Convert the psion Word file FILE to other formats"); puts("If FILE is not specified, use stdin"); puts(" -d, --debug Show debug information on stderr"); puts(" -h, --help Display this help and exit"); @@ -60,6 +76,7 @@ puts(" -T, --type=FILETYPE Output type"); puts(" -V, --version Display the program version and exit"); puts(" -v, --verbose Show progress indicators on stderr"); + puts(" -u, --UTF8 Input file is encoded in UTF8"); puts(""); puts("The following output types are known:"); for (i = 0; i < psiconv_list_length(fileformat_list); i ++) { @@ -69,6 +86,9 @@ putchar(' '); puts(ff->description); } + puts(""); + puts("When using UTF8 with LaTeX type, the resulting LaTeX source should be converted"); + puts(" to a suitable encoding for your LaTeX installation before being typeset"); } void print_version(void) @@ -94,9 +114,10 @@ {"silent",no_argument,NULL,'s'}, {"outputfile",required_argument,NULL,'o'}, {"type",required_argument,NULL,'T'}, + {"UTF8",no_argument,NULL,'u'}, {0,0,0,0} }; - const char* short_options = "hVvsdo:eT:"; + const char* short_options = "hVvsdo:uT:"; int option_index; FILE * f; struct stat fbuf; @@ -104,6 +125,7 @@ const char *inputfilename = ""; const char *outputfilename = ""; char *type = strdup("HTML3"); + psiconv_encoding encoding_type=PSICONV_ENCODING_CP1252; int c,i,res; psiconv_buffer buf; @@ -134,6 +156,7 @@ case 's': psiconv_verbosity = PSICONV_VERB_FATAL; break; case 'o': outputfilename = strdup(optarg); break; case 'T': type = strdup(optarg); break; + case 'u': encoding_type = PSICONV_ENCODING_UTF8; break; case '?': case ':': fputs("Try `-h' for more information\n",stderr); exit(1); default: fprintf(stderr,"Internal error: getopt_long returned character " @@ -186,8 +209,8 @@ strtoupper(type); for (i = 0; i < psiconv_list_length(fileformat_list); i ++) { ff = psiconv_list_get(fileformat_list,i); - if (! strcmp(type,ff->name)) { - res = ff->output(outputfilename,file,type); + if (! strcasecmp(type,ff->name)) { + res = ff->output(outputfilename,file,type, encoding_type); if (res) { fprintf(stderr, "Output format `%s' not permitted for this file type\n",type);