|

楼主 |
发表于 2004-11-29 10:43:40
|
显示全部楼层
下面写了一段 C 的代码, 是用来将 unicon cce 模块、scim、fcitx 等的码表格式转换成 Windows 下 输入法生成器 的码表源文件格式, 上面提供的 Windows 输入法生成器的码表源文件就是用这段代码转换的.
- #include <stdio.h>
- #include <stdlib.h>
- #define MAXLENTH 30
- #define MAXLENTH_WIN 12
- /* Change scim, Unicon-cce, fcitx ... table to Win32 format */
- main( int argc, char *argv[] )
- {
- int str1[MAXLENTH], str2[MAXLENTH];
- FILE *fp1, *fp2;
- if (argc != 3)
- {
- printf("\nUsage: u2win32 <Source File> <File Out>\n");
- exit (1);
- }
- else
- ;
- if ((fp1 = fopen (argv[1], "r")) == NULL)
- {
- printf ("Error: Failed to read file %s "
- "or file does not exist!\n", argv[1]);
- exit (2);
- }
- else
- ;
- if ((fp2 = fopen (argv[2], "w")) == NULL)
- {
- printf ("Error: Failed to create or write file %s!\n", argv[2]);
- exit (3);
- }
- else
- ;
- fprintf (fp2,
- "[Description]\r\n"
- "Name=%s\r\n"
- "MaxCodes=%d\r\n"
- "MaxElement=%d\r\n"
- "UsedCodes=%s\r\n"
- "WildChar=%s\r\n"
- "[Text]\r\n",
- "Wu",
- MAXLENTH_WIN,
- 2,
- "'abcdefghijklmnopqrstuvwxyz",
- "?");
- while (fscanf (fp1, "%s", str1) != EOF)
- {
- fscanf (fp1, "%s", str2);
- fprintf (fp2, "%s%s\r\n", str2, str1);
- }
- fclose (fp1);
- fclose (fp2);
- return 0;
- }
复制代码 |
|