J
jvyyuie
// My email is (e-mail address removed)
// I want to make some friends and discuss about programing.
#include "stdafx.h"
#include <malloc.h>
#include <string.h>
#define sec1 (c=buffer)&&(c>0x80&&c<0xA1||c>0xA9&&c<0xFF)
#define sec2 (c=buffer)&&(c>0xA0&&c<0xAA)
void Convert2PureChinese(unsigned char* buffer)
{
unsigned char c;
for(int i=0;i<(int)strlen((char*)buffer)
if(sec1)
{
printf("%c%c", buffer, buffer[i+1]);
i+=2;
}
else if(sec2)
i+=2;
else
i++;
}
void getFileBuffer(FILE* fp)
{
if(fp==NULL)
return;
fseek(fp, 0L, SEEK_END);
long len=ftell(fp);
rewind(fp);
unsigned char* buffer=(unsigned char*)malloc(len);
fread(buffer, len, 1, fp);
fclose(fp);
Convert2PureChinese(buffer);
free(buffer);
}
int main(int argc, char* argv[])
{
getFileBuffer(fopen("test.txt", "r+b"));
return 0;
}
// I want to make some friends and discuss about programing.
#include "stdafx.h"
#include <malloc.h>
#include <string.h>
#define sec1 (c=buffer)&&(c>0x80&&c<0xA1||c>0xA9&&c<0xFF)
#define sec2 (c=buffer)&&(c>0xA0&&c<0xAA)
void Convert2PureChinese(unsigned char* buffer)
{
unsigned char c;
for(int i=0;i<(int)strlen((char*)buffer)
if(sec1)
{
printf("%c%c", buffer, buffer[i+1]);
i+=2;
}
else if(sec2)
i+=2;
else
i++;
}
void getFileBuffer(FILE* fp)
{
if(fp==NULL)
return;
fseek(fp, 0L, SEEK_END);
long len=ftell(fp);
rewind(fp);
unsigned char* buffer=(unsigned char*)malloc(len);
fread(buffer, len, 1, fp);
fclose(fp);
Convert2PureChinese(buffer);
free(buffer);
}
int main(int argc, char* argv[])
{
getFileBuffer(fopen("test.txt", "r+b"));
return 0;
}