📄 chintopy.c
字号:
#include <stdio.h>
#include <string.h>
#include <conio.h>
int StrToPYM(unsigned char *str,unsigned char *pystr);
int ChineseToPY(unsigned int ChinCode, unsigned char *pystr);
unsigned char* testStr = "王维琨李杰";
void main(void)
{
unsigned char pystr[300];
StrToPYM(testStr, pystr);
printf(pystr);
}
int StrToPYM(unsigned char *str,unsigned char *pystr)
{
unsigned int f = 0 ;
unsigned int ChinCode,firstcode;
unsigned char i,j;
unsigned char strp[3];
memset(pystr, 0, 6);
j=0;
while((i = *str++) != '\0')
{
if(i > 0xa0)
{
if(f==0)
{
firstcode =(unsigned int)i;
f++;
}
else
{
ChinCode= firstcode<<8;
ChinCode+=(unsigned int)i;
f= 0 ;
ChineseToPY(ChinCode,strp);
pystr[j]=strp[0];
j++;
}
}else break;
}
pystr[j]=0;
return j ;
}
int ChineseToPY(unsigned int ChinCode, unsigned char *pystr)
{
FILE *fp;
unsigned long offset ;
int j=1;
fp = fopen("pysx.txt", "r+") ;
rewind(fp);
offset=(unsigned long)(((((ChinCode & 0x7f00)>>8) - 0x30) * 94 + (ChinCode & 0x007f) - 0x21))<<1;
fseek(fp, offset, SEEK_SET);
pystr[0]=fgetc(fp);
if((pystr[1]=fgetc(fp))!=' ') j=2;
pystr[2]=0x00;
fclose(fp);
return j ;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -