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

📄 unicodetransdlg.cpp

📁 不错的转换工具
💻 CPP
📖 第 1 页 / 共 2 页
字号:
			count ++;
			toWrite.Empty();
		}

	}

	j++;
	toWrite.Empty();
	
	toWrite += '\n';
	toWrite += "STRING_MAX ";
	toWrite += '=';
	strTemp.Format("%d", j);
	toWrite += strTemp;
	toWrite += '\n';
	toWrite += "}MMIStringID_t;";

	toWrite += '\n';
	toWrite += '\n';
    toWrite += "#ifndef FEATURE_HUNTEL_CDG2_TEST";
	toWrite += '\n';
	toWrite += "#define STRID_MAX_LENGTH    20";
	toWrite += '\n';
	toWrite += "#define MAXSTRLEN  20";
	toWrite += '\n';
	toWrite += "#else";
    toWrite += '\n';
    toWrite += "#define STRID_MAX_LENGTH    25";
	toWrite += '\n';
	toWrite += "#define MAXSTRLEN 25";
    toWrite += '\n';
	toWrite += "#endif";
	toWrite += '\n';
	toWrite += '\n';
	toWrite += "#endif";
	toWrite += '\n';
	f.Write(toWrite, toWrite.GetLength());/*写文件*/

	f.Close();
	DspBuf = "已经生成resID.h" ;
	m_AccessList.AddString(DspBuf);
	return true;
}

bool CUniCodeTransDlg::WriteCnResStr()
{
WCHAR * StrBuf;
WCHAR wszUserName[100] = {0};          // Unicode user name
int len;
char check[2];
CFileException e;
int j;
char temp[30];
CString toWrite;
int count = 0;
CString	DspBuf;

	memset(temp,0,30);
	memset(check,0,2);

    char* pFileName = "\\numan\\apps\\brew\\application\\inc\\resStrTab.h";
	/*打开文件,如果不存在就创建该文件*/
	if( !f.Open( pFileName, CFile::modeCreate | CFile::modeWrite | CFile::typeText) )
	{
	/*	AfxMessageBox("resStrTab.h文件属性只读,请先checkout");*/
		DspBuf = "resStrTab.h文件属性只读,请先checkout" ;
		m_AccessList.AddString(DspBuf);
		j = m_AccessList.GetCount();
		if (j > 0)
			m_AccessList.SetCurSel(j-1);
		return false;
	}
	j = 0;
	COleDateTime dateTest = COleDateTime::GetCurrentTime();
	CString dateStr;

	/*写文件头*/

	toWrite += "#ifndef RESCNTAB_H";/*文件头*/
	toWrite += '\n';
	toWrite += "#define RESCNTAB_H";
	toWrite += '\n';

	toWrite += "/*-------------------------------------------*/";
	toWrite += '\n';
	toWrite += "/*   this is func of make the res id file    */";
	toWrite += '\n';
	toWrite += "/*   author: jian ai,jf jiang Huntel tech.   */";
	toWrite += '\n';
	dateStr.Format("/*   %s      */", dateTest.Format("%A, %B %d, %Y, %H:%M:%S"));
	toWrite += dateStr;
	toWrite += '\n';
	toWrite += "/*   filename: RESCNSTR.i                    */";
	toWrite += '\n';
	toWrite += "/*-------------------------------------------*/";
	toWrite += '\n';
	toWrite += " #include ";
	toWrite += '"';
	toWrite += "comdef.h";
	toWrite += '"';

	toWrite += '\n';
	toWrite += '\n';
	toWrite += '\n';
	toWrite += '\n';

	toWrite += "typedef struct {";
	toWrite += '\n';

	toWrite += 9;
	toWrite += "uint8   lenth_cn;";
	toWrite += '\n';

	toWrite += 9;
	toWrite +="uint16  cnStrRes[MAXSTRLEN];";
	toWrite += '\n';

	
	toWrite += 9;
	toWrite += "uint8   lenth_en;";
	toWrite += '\n';

	toWrite += 9;
	toWrite += "uint8  enStrRes[MAXSTRLEN];";
	toWrite += '\n';

	toWrite += "}StringDefinitionType;";
	toWrite += '\n';
	toWrite += '\n';
	toWrite += '\n';

	toWrite += "const StringDefinitionType resstrtbl[] = {";
	toWrite += '\n';
	toWrite += '{';
	toWrite += '\n';
	toWrite += '0';
	toWrite += ',';
	toWrite += '\n';
	toWrite += "{NULL},";
	toWrite += '\n';
	toWrite += '0';
	toWrite += ',';
	toWrite += '\n';
	toWrite += "{NULL},";
	toWrite += '\n';
	toWrite += "},";
	toWrite += '\n';

	f.Write(toWrite,toWrite.GetLength());
	toWrite.Empty();
	
	/*从ResID中读取内容并且进行转换*/
	len = (nLengthNeedTranStr/2 + nLengthNeedTranStr%2);

	StrBuf = (WCHAR *)malloc(len*sizeof(WCHAR));

	memcpy(StrBuf,(LPCTSTR)ResCnStr,len*sizeof(WCHAR));

	for(int i = 0; i < len; i++ )
	{
		check[0] = (char)((StrBuf[i] >> 8)&0x00FF);
		if(check[0] == 15)
		{
			CString  strTemp;

			memset(wszUserName, 0, 100 * sizeof(WCHAR));
			/*转换*/
			MultiByteToWideChar( CP_ACP, 0, temp, strlen(temp), wszUserName,  strlen(temp) * 2);			


			/*写当前字符串的id*/
			toWrite += '{';
			toWrite += 9;
			toWrite += "/*";
			toWrite += StrIDBuf[count];
			toWrite += "*/";
			count++;
			toWrite += '\n';
			

			toWrite += 9;
			strTemp.Format("%d,",wcslen(wszUserName));
			toWrite += strTemp;
			toWrite += 9; /*tab键*/
			toWrite += "/*chinese string length*/";
			toWrite += '\n';
			toWrite += 9; /*tab键*/
			toWrite+="{";

			for(int k=0; k < wcslen(wszUserName) ; k++)/*写字串内容(中文)*/
			{	
			
				strTemp.Format("0x%.2x", (wszUserName[k]>>8)&0x00ff);
				toWrite += strTemp;
				strTemp.Format("%.2x,", wszUserName[k]&0x00ff);
				toWrite += strTemp;
			}
			toWrite +="},";
			toWrite += '\n';
			f.Write(toWrite, toWrite.GetLength());/*写文件*/

			WriteEnBuf(count);/*写英文资源*/

			toWrite.Empty();
			toWrite += '\n';
			toWrite += '}';
			toWrite += ',';
			toWrite += '\n';
			f.Write(toWrite, toWrite.GetLength());/*写文件*/

			toWrite.Empty();
			memset(temp, 0, strlen(temp));

			j = 0;

		}else
		{
			char a = (char)(StrBuf[i]&0x00FF);
			if(a != 0)	temp[j++] = a;
			a = (char)((StrBuf[i] >> 8)&0x00FF);		
			if(a != 0)	temp[j++] = a;
		}
	}

	toWrite.Empty();

	toWrite += '\n';/*文件结尾*/
	toWrite += '}';
	toWrite += ';';
	toWrite += '\n';
	toWrite += '\n';
	toWrite += '\n';
	toWrite += "#endif";
	toWrite += '\n';
	f.Write(toWrite, toWrite.GetLength());/*写文件*/

	f.Close();
	DspBuf = "已经生成resStrTab.h" ;
	m_AccessList.AddString(DspBuf);
	DspBuf = "转换成功,生成文件!目录位于\\numan\\apps\\brew\\application\\inc" ;
	m_AccessList.AddString(DspBuf);
	j = m_AccessList.GetCount();
	if (j > 0)
		m_AccessList.SetCurSel(j-1);
	free(StrBuf);
	StrBuf = NULL;
	/*AfxMessageBox("转换成功,生成文件!(目录:\\numan\\apps\\brew\\application\\inc)");*/
	return true;
}

void CUniCodeTransDlg::WriteEnBuf(int count)
{	
	CString InBuf;
	char temp[30];
	WCHAR wszUserName[100] = {0};          // Unicode user name
	int j = 0;
	char * StrBuf;
	char check[2];
	memset(temp,0,30);
	CString strTemp;

	int count_now = 0;

	int length = ResEnStr.GetLength();

	StrBuf = (char *)malloc(length);

	memcpy(StrBuf,(LPCTSTR)ResEnStr,length);

	for(int i = 0; i <length; i++)
	{
		check[0] = StrBuf[i];
		if(check[0] ==15)
		{
			count_now++;
			if(count_now == count)/*当前串*/
			{

				
				MultiByteToWideChar( CP_ACP, 0, temp, strlen(temp), wszUserName,  strlen(temp) * 2);

				InBuf += 9;
				strTemp.Format("%d,",wcslen(wszUserName));
				InBuf += strTemp;
				InBuf += 9; /*tab键*/
				InBuf += "/* English string length */";
				InBuf += '\n';

				InBuf += 9;
				InBuf += '{';
				for(int k=0; k < wcslen(wszUserName) ; k++)
				{	
					strTemp.Format("0x%.2x", wszUserName[k]&0x00ff);
					InBuf += strTemp;
					InBuf += ',';
				}
				InBuf +="},";
				InBuf += "  /* English String */";

				f.Write(InBuf, InBuf.GetLength());/*写文件*/
				free(StrBuf);
				StrBuf = NULL;
				return ;
			}else
			{
				memset(temp,0,sizeof(temp));
				j = 0;
				continue;
			}

		}else
		{
			temp[j++] = StrBuf[i];
		}
	}


	free(StrBuf);
	StrBuf = NULL;
	
}



void CUniCodeTransDlg::WriteStringNameWithCount(int count)
{
	int count_now = 0;
	int j = 0;
	char check[2];
	char  Temp[30];
	CString InBuf;
	WCHAR * StrBuf;
	CString		DspBuf;

	memset(Temp, 0, sizeof(Temp));

	int length = ResCnStr.GetLength();

	StrBuf = (WCHAR *)malloc(length*sizeof(WCHAR));

   
	memcpy(StrBuf ,(LPCTSTR)ResCnStr,length);
	
	for(int i = 0; i < length; i++ )
	{
		check[0] = (char)((StrBuf[i] >> 8)&0x00FF);

		if(check[0] ==15)
		{
			
			count_now++;
			if(count_now == count)
			{
				InBuf += 9;
				InBuf += "/* ";
				InBuf += Temp;
				InBuf += " */";

				f.Write(InBuf, InBuf.GetLength());/*写文件*/
				DspBuf = InBuf;
				m_AccessList.AddString(DspBuf);
				break;
				
			}else
			{
				memset(Temp,0,sizeof(Temp));
				j = 0;
				continue;
			}
		}else
		{
			
			char a = (char)(StrBuf[i]&0x00FF);
			if(a != 0)	Temp[j++] = a;
			a = (char)((StrBuf[i] >> 8)&0x00FF);		
			if(a != 0)	Temp[j++] = a;
		}
	}

	free(StrBuf);
	StrBuf = NULL;
}

void CUniCodeTransDlg::WriteStringEnglishNameWithCount(int count)
{
	int count_now = 0;
	int j = 0;
	char  Temp[30];
	CString InBuf;
	char * StrBuf;
	CString		DspBuf;

	memset(Temp, 0, sizeof(Temp));

	int length = ResEnStr.GetLength();

	StrBuf = (char*)malloc(length);

   
	memcpy(StrBuf, ResEnStr,length);
	
	for(int i = 0; i < length; i++ )
	{
		if (StrBuf[i] == 0xf)
		{
			
			count_now++;
			if(count_now == count)
			{
				InBuf += 9;
				InBuf += "/* ";
				InBuf += Temp;
				InBuf += " */";
				InBuf += '\n';

				f.Write(InBuf, InBuf.GetLength());/*写文件*/
				DspBuf = InBuf;
				m_AccessList.AddString(DspBuf);
				break;
				
			}else
			{
				memset(Temp,0,sizeof(Temp));
				j = 0;
				continue;
			}
		}else
		{
			Temp[j++] = StrBuf[i];
		}
	}

	free(StrBuf);
	StrBuf = NULL;
}

⌨️ 快捷键说明

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