char * iToLoFont(int i) //将两字节i转换为"/x00/x00"形式,低位在前
{
int len;
char hex[8]="";
char formatstr[12]="";
itoa(i,hex,16);
len = strlen(hex);
switch(len)
{
case 1:
strcat(formatstr,"\\x0");
strcat(formatstr,hex);
strcat(formatstr,"\\x00");
break;
case 2:
strcat(formatstr,"\\x");
strcat(formatstr,hex);
strcat(formatstr,"\\x00");
break;
case 3:
strcat(formatstr,"\\x");
strncat(formatstr,hex+1,2);
strcat(formatstr,"\\x0");
strncat(formatstr,hex,1);
break;
case 4:
strcat(formatstr,"\\x");
strncat(formatstr,hex+2,2);
strcat(formatstr,"\\x");
strncat(formatstr,hex,2);
break;
}
return formatstr;
//lr_output_message("iToLoFont return %s",formatstr);
}
char * iToHiFont(int i)//将两字节i转换为"/x00/x00"形式,高位在前
{
int len;
char hex[8]="";
char formatstr[12]="";
itoa(i,hex,16);
len = strlen(hex);
switch(len)
{
case 1:
strcat(formatstr,"\\x00\\x0");
strcat(formatstr,hex);
break;
case 2:
strcat(formatstr,"\\x00\\x");
strcat(formatstr,hex);
break;
case 3:
strcat(formatstr,"\\x0");
strncat(formatstr,hex,1);
strcat(formatstr,"\\x");
strncat(formatstr,hex+1,2);
break;
case 4:
strcat(formatstr,"\\x");
strncat(formatstr,hex,2);
strcat(formatstr,"\\x");
strncat(formatstr,hex+2,2);
break;
}
return formatstr;
//lr_output_message("iToHiFont return %s",formatstr);
}