⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 encodeenglish.cpp

📁 手机开发环境BREW实例
💻 CPP
字号:
// EncodeEnglish.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <memory.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>

int Hex(int nValue)
{
        switch (nValue)
        {
          case 0:
                nValue=0x7f;
                break;
          case 1:
                nValue=0x3f;
                break;
          case 2:
                nValue=0x1f;
                break;
          case 3:
                nValue=0x0f;
                break;
          case 4:
                nValue=0x07;
                break;
          case 5:
                nValue=0x03;
                break;
          case 6:
                nValue=0x01;
                break;
          case 7:
                nValue=0x00;
                break;
        }
        return nValue;
}

int DecodeEnglish (char * InputStr,char * OutputStr)
{
        unsigned int InStr[300];
        char OutStr[300];
        char str[3];
        unsigned int j=0;
		unsigned int i=0;
        int Point=0;
 //      int temp;
        memset(InStr,0,300);
        memset(OutStr,0,300);
		memset(str,0,3);
		char *strTemp;
		long lngTemp;
        for(i=0;i<strlen(InputStr);i=i+2)
        {
			strncpy(str,(char * )(InputStr + i),2);
			str[2] = '\0';
			lngTemp = strtoul(str,&strTemp,16);
			InStr[i/2] = lngTemp;
        }
		i = 0;
        while(j<=strlen(InputStr)/2)
        {
                if(Point==0)
                     OutStr[i]=InStr[j]&Hex(Point);
                else
					OutStr[i]=((InStr[j]&Hex(Point))<<Point)|(InStr[j-1]>>(8-Point));
                if(Point%7==0&&Point!=0)
                        Point=0;
                else
                        Point=Point+1;
                i++;
                j=i-(i/8);
        }
		sprintf(OutputStr,"%s",OutStr);
        return 0;
}



int main(int argc, char* argv[])
{
	int nRet;
	char strTest[1024];
	char strOutTest[1024];
//	int nOutBuff = 1024;
	sprintf(strTest,"%s","C8329BFD4696D9ECF7F52D679301");

	nRet = DecodeEnglish(strTest,strOutTest);
	if (nRet != 0)
	{
		printf("Encode English Fail!\n");
		return -1;
	}
	printf("%s\n",strOutTest);
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -