|
![]() | 作者: ypy [ypy]
![]() |
登录 |
我想在BCB中实现把文本文件中的内容转换成16进制ASCII码,代码中一部分如下: pszBuffer=new char[iFileLength+1]; //读取文件内容 iBytesRead=FileRead(iFileHandle,pszBuffer,iFileLength); FileClose(iFileHandle); //转换成16进制ASCII码 for(j=0;j<iBytesRead;j++) { sprintf(hexchar,"%02x",int(pszBuffer[j])); hexBuffer+=AnsiString(hexchar).UpperCase(); } delete []pszBuffer; iFileHandle=FileCreate(ListBox1->Items->Strings[i]); iFileLength=hexBuffer.Length()+100; //把16进制ASCII码写入文件 FileWrite(iFileHandle,hexBuffer.c_str(),iFileLength); FileClose(iFileHandle); 其中前面的iFileHandle为读入内容的文件句柄,文件长度iFileLength值已定。 几个变量的声明: int i; int j; int iFileHandle; int iFileLength; int iBytesRead; char *pszBuffer; AnsiString hexBuffer; char hexchar[4]; 头文件包括: #include <SysUtils.hpp> #include <stdio.h> 请教:为什么对文件中的中文不能正确处理,我该怎么改才正确? 谢谢了各位! [此贴被 ypy(ypy) 在 03月22日23时00分 编辑过] |
地主 发表时间: 2003-03-22 23:17:00 |
![]() | 回复: ypy [ypy] ![]() |
登录 |
各位请帮帮忙啊 |
B1层 发表时间: 03/23 22:44 |
![]() | 回复: 286 [unique] ![]() |
登录 |
不好意思,我只是试试我能否在这里发音。 该问题具体回答请参见“菜鸟乐园”同题回答。 [此贴被 286(unique) 在 03月24日12时23分 编辑过] |
B2层 发表时间: 2003-03-24 12:43:23 |
|
20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon
粤ICP备05087286号