如何将hex值转为字符串
3个回答
展开全部
每两个字符前面加一个%,然后用decodeURI转换就行了
文件必须存成utf-8格式
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<div id="d1">
<script type="text/javascript">
var hi = '7465737420e6b58be8af95';
//var hj = '%74%65%73%74%20%e6%b5%8b%e8%af%95';
var hj = prePro(hi);
document.write(hi);
document.write('<br />');
document.write(hj);
document.write('<br />');
document.write(decodeURI(hj));
function prePro(data)
{
if (data.length % 2) return '';
var tmp='';
for(i=0;i<data.length;i+=2)
{
tmp += '%' + data.charAt(i) + data.charAt(i+1);
}
return tmp;
}
</script>
</div>
</body>
</html>
文件必须存成utf-8格式
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<div id="d1">
<script type="text/javascript">
var hi = '7465737420e6b58be8af95';
//var hj = '%74%65%73%74%20%e6%b5%8b%e8%af%95';
var hj = prePro(hi);
document.write(hi);
document.write('<br />');
document.write(hj);
document.write('<br />');
document.write(decodeURI(hj));
function prePro(data)
{
if (data.length % 2) return '';
var tmp='';
for(i=0;i<data.length;i+=2)
{
tmp += '%' + data.charAt(i) + data.charAt(i+1);
}
return tmp;
}
</script>
</div>
</body>
</html>
推荐于2016-05-03
展开全部
原型:
void WINAPI icePub_BCDHexToHexString(BYTE *hexBuffer,BYTE *strHexString,int hexBufferLen)
输入:hexBuffer hex数据
hexBufferLen hexBuffer的长度
输出:strHexString 展开后hex文本串
返回码:
extern "C"
{
__declspec(dllexport)
void WINAPI icePub_BCDHexToHexString(BYTE *hexBuffer,BYTE *strHexString,int hexBufferLen);
}
#pragma comment(lib,"icePubDll.lib")
char str1[128];
icePub_BCDHexToHexString("月光",str1,8);
AfxMessageBox(str1);
Private Declare Function icePub_BCDHexToHexString Lib "icePubDll.dll" (ByVal hexBuffer As String,ByVal strHexString As String,ByVal hexBufferLen As Integer) As Integer
Dim str1 As String
Dim a2 As Integer
str1=Space(1024*30)
a2=icePub_BCDHexToHexString("月光",str1,8)
MsgBox str1
void WINAPI icePub_BCDHexToHexString(BYTE *hexBuffer,BYTE *strHexString,int hexBufferLen)
输入:hexBuffer hex数据
hexBufferLen hexBuffer的长度
输出:strHexString 展开后hex文本串
返回码:
extern "C"
{
__declspec(dllexport)
void WINAPI icePub_BCDHexToHexString(BYTE *hexBuffer,BYTE *strHexString,int hexBufferLen);
}
#pragma comment(lib,"icePubDll.lib")
char str1[128];
icePub_BCDHexToHexString("月光",str1,8);
AfxMessageBox(str1);
Private Declare Function icePub_BCDHexToHexString Lib "icePubDll.dll" (ByVal hexBuffer As String,ByVal strHexString As String,ByVal hexBufferLen As Integer) As Integer
Dim str1 As String
Dim a2 As Integer
str1=Space(1024*30)
a2=icePub_BCDHexToHexString("月光",str1,8)
MsgBox str1
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
IntToHex
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |