- 论坛徽章:
- 0
|
是的,我的方法是在把导出的文本转换成xml文件时使用的,对于把导出的文本再导入其它数据库还真没试过,不过,我之前写过一段代码不知对你有没有用处:
- #include <stdio.h>
- void main(int argc, char *argv[])
- {
- FILE *fsrc, *fdes;
- char *src, *des;
- unsigned char ch1, ch2;
- if(argc != 3) {
- printf("Usage: eraseHalfCh.exe src des\n");
- exit(1);
- }
- src = (char*) malloc ((strlen(argv[1]) + 1) * sizeof(char));
- if(src == NULL) {
- printf("Out of memory!\n");
- exit(1);
- }
- des = (char*) malloc ((strlen(argv[2]) + 1) * sizeof(char));
- if(des == NULL) {
- printf("Out of memory!\n");
- exit(1);
- }
- memset(src, 0, (strlen(src) + 1) * sizeof(char));
- memset(des, 0, (strlen(des) + 1) * sizeof(char));
- memcpy(src, argv[1], strlen(argv[1]));
- memcpy(des, argv[2], strlen(argv[2]));
- fsrc = fopen(src, "r");
- if(fsrc == NULL) {
- printf("Error to open file %s\n", src);
- exit(1);
- }
- fdes = fopen(des, "w");
- if(fdes == NULL) {
- printf("Error to open file %s\n", des);
- exit(1);
- }
- ch1 = fgetc(fsrc);
- while(!feof(fsrc)) {
- if(ch1 > 0xA0) { /* 说明是汉字 */
- ch2 = fgetc(fsrc);
- if(ch2 > 0xA0) { /* 说明是一个完整的汉字 */
- fputc(ch1, fdes);
- fputc(ch2, fdes);
- } else { /* 说明是半个汉字需将其去除 */
- fputc(ch2, fdes);
- }
- } else { /* 不是汉字直接写入 */
- fputc(ch1, fdes);
- }
- ch1 = fgetc(fsrc);
- }
- fclose(fsrc);
- fclose(fdes);
- }
复制代码 |
|