#include <windows.h>
#include <stdio.h>
int main(int argn, char * argv[]) {
FILE *fp;
if (argn < 2) {
MessageBox(0, "Where is second argument?", "PVH", 0);
return 0;
}
int iFile;
for (iFile = 1; iFile < argn; iFile++) {
fp = fopen(argv[iFile], "r");
if (!fp) {
MessageBox(0, "Read file failed", "PVH", 0);
continue;
}
char szString[65535];
int nRead = fread(szString, sizeof(char), 65535, fp);
//printf("%d ", nRead);
int iStart = 0;
int iFinish = nRead;
if(szString[0] == -17 && szString[1]==-69 && szString[2]==-65) {
printf("BOM will be removed");
iStart = 3;
}
rewind(fp);
fclose(fp);
if (iStart == 0) continue;
fp = fopen(argv[iFile], "w+"); int i;
for (i = iStart; i < iFinish; i++) {
fputc(szString[i], fp);
}
fclose(fp);
}
return 1;
}
Title:
Convert From Unicode Signature (BOM) to Unicode
Description:
#include <windows.h> #include <stdio.h> int main(int argn, char * argv[]) { FILE *fp; if (argn < 2) { ...
...
Rating:
4