守卫剑阁 物品代码 转换工具

数字转字符


字符转数字


<p>
<style>
.btn {
    font-family: "tahoma", "宋体";
    font-size:12pt; color: #003399;
    border: 1px #003399 solid;
    color:#006699;
    border-bottom: #93bee2 1px solid;
    border-left: #93bee2 1px solid;
    border-right: #93bee2 1px solid;
    border-top: #93bee2 1px solid;
    background-color: #e8f4ff;
    cursor: hand;
    font-style: normal ;
    width:auto;
    height:40px;
    float:left;
}

.txt {
    font-family: "tahoma", "宋体";
    font-size:16pt; color: #003399;
    border: 1px #003399 solid;
    color:#006699;
    border-bottom: #93bee2 1px solid;
    border-left: #93bee2 1px solid;
    border-right: #93bee2 1px solid;
    border-top: #93bee2 1px solid;
    text-align: center;
    cursor: hand;
    font-style: normal ;
    width:auto;
    height:36px;
    float:left;
}

</style>

<input id="1" class="txt" type="text" /> 
<button class="btn" οnclick="i2a()" type="button">数字转字符</button> 
<input id="2" class="txt" type="text" />
<br />
<br />
<br />
<input id="3" class="txt" type="text" /> 
<button class="btn" οnclick="a2i()" type="button">字符转数字</button> 
<input id="4" class="txt" type="text" />
<script>

function i2a()
{
    //1919707494
    //726c6966
    //0x72 0x6c 0x69 ox66
    //r l i f
    var txt1 = document.getElementById("1")
    var txt2 = document.getElementById("2")
    txt2.value =null
    var dif = new Array(0)
    var x = (parseInt(txt1.value)).toString(16)

    

    for(var i=0;i<x.length;i+=2)
    {
        dif.push(parseInt(x.slice(i,i+2),16))
    }

    for (var i=0;i<dif.length;i++)
    {
        //
        txt2.value += String.fromCharCode(dif[i]);
    }
    //console.log(dif)
}

function a2i()
{
    //r l i f
    //0x72 0x6c 0x69 ox66
    //726c6966
    //1919707494
    var txt3 = document.getElementById("3")
    var txt4 = document.getElementById("4")
    txt4.value=null
    var dif = new Array(0)
    var x = txt3.value
    var y =""

    for(var i=0;i<x.length;i++)
    {
        //
        dif.push((x[i].charCodeAt()).toString(16))
    }
    
    for(var i=0;i<dif.length;i++)
    {
        //
        y += dif[i]
    }

    txt4.value = parseInt(y,16)
}
</script>
<br /><br /><br />
</p>
View Code

 

转载于:https://www.cnblogs.com/jhcla/p/6036752.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值