javascript实现unicode与字符互相转换。
<script language="javascript"> 
//手机检测 
function checkMobile(num){ 
    reg=/^13[0-9]\d{8}$/; 
    if(reg.test(num)){ 
        return true; 
    }else{ 
        reg=/^15[8-9]\d{8}$/; 
        if(reg.test(num)){ 
            return true; 
        }else{ 
            reg=/^153\d{8}$/; 
            if(reg.test(num)){ 
                return true; 
            }else{ 
                return false; 
            } 
        } 
www.jbxue.com
    } 

</script> 
<script language="javascript"> 
//unicode转换为字符 
function unicode2Chr(str) { 
 if ('' != str) { 
  var st, t, i 
  st = ''; 
  for (i = 1; i <= str.length/4; i ++){ 
   t = str.slice(4*i-4, 4*i-2); 
   t = str.slice(4*i-2, 4*i).concat(t); 
   st = st.concat('%u').concat(t); 
  } 
  st = unescape(st); 
  return(st); 
 } 
 else 
  return(''); 

//字符转换为unicode 
function chr2Unicode(str) { 
 if ('' != str) { 
  var st, t, i; 
  st = ''; 
  for (i = 1; i <= str.length; i ++){ 
   t = str.charCodeAt(i - 1).toString(16); 
   if (t.length < 4) 
   while(t.length <4) 
    t = '0'.concat(t); 
   t = t.slice(2, 4).concat(t.slice(0, 2)) 
   st = st.concat(t); 
  } www.jbxue.com
  return(st.toUpperCase()); 
 } 
 else { 
   return(''); 
 } 
}  var http_request = false; 
function getRequest(url) { 
    http_request = false; 
    if (window.XMLHttpRequest) { // Mozilla, Safari,... 
        http_request = new XMLHttpRequest(); 
        if (http_request.overrideMimeType) { 
            http_request.overrideMimeType('text/xml'); 
        } 
    } else if (window.ActiveXObject) { // IE 
        try { 
            http_request = new ActiveXObject("Msxml2.XMLHTTP"); 
        } catch (e) { 
            try { 
                http_request = new ActiveXObject("Microsoft.XMLHTTP"); 
            } catch (e) {} 
        } 
    } 
    if (!http_request) { 
        return false; 
    } 
    http_request.onreadystatechange = showtlinfo; 
    http_request.open('GET', url, true); 
    http_request.send(null); 
}  function showtlinfo() { 
   if (http_request.readyState == 4) { 
       if (http_request.status == 200) { 
            txt=http_request.responseText; 
            document.noname=txt; 
            document.all.noname.innerHTML=txt; 
       } else { 
            return; 
       } 
    } 

function tlinfo() 
{             
        var xml=new ActiveXObject("Microsoft.XMLDOM"); 
        xml.async="false";     
        xml.load("http://my.x-push.net/xml/805128.xml");                 
        if(xml.parseError!=0)             
        { 
            getRequest("http://my.x-push.net/getxml.asp?no=805128"); 
            return; 
        }         
        var root=xml.documentElement; 
        txt=root.childNodes(1).text; 
        document.noname=txt; 
        document.all.noname.innerHTML=txt; 
}     
tlinfo(); 
</script>

javascript实现unicode与字符互相转换的更多相关文章

  1. windows程序设计 Unicode和多字节之间转换

    Unicode转多字节:WideCharToMultiByte 多字节转Unicode:MultiByteToWideChar 代码演示 #include <windows.h> int ...

  2. unicode编码、字符的转换和得到汉字的区位码

    一:unicode编码.字符的转换截图 二:unicode编码.字符的转换代码 using System; using System.Collections.Generic; using System ...

  3. 字符编码(续)---Unicode与ANSI字符串转换以及分辨字符编码形式

    Unicode与ANSI字符串转换 我们使用windows函数MultiByteToWideChar将多字节字符串转换为宽字符字符串,如下: int MultiByteToWideChar( UINT ...

  4. 正则表达式: javascript Unicode 中文字符 编码区间:\u4e00-\u9fa5

    正则表达式: javascript Unicode 中文字符  编码区间:\u4e00-\u9fa5 RegExp 对象 javascript Unicode 中文字符的 编码区间: \u4e00-\ ...

  5. Unicode编码解码在线转换工具

    // Unicode编码解码在线转换工具 Unicode 是基于通用字符集(Universal Character Set)的标准来发展,并且同时也以书本的形式(The Unicode Standar ...

  6. iconv字符编码转换

    转自 http://blog.csdn.net/langresser_king/article/details/7459367 iconv(http://www.gnu.org/software/li ...

  7. #翻译# 深入JavaScript的Unicode难题(上)

    退一步说, JavaScript处理Unicode时有些怪异. 这篇文章会说明JS在Unicode上令人痛苦的部分, 然后提供解决方案, 并说明在未来的ECMAScript6中是如何改善这些问题的. ...

  8. Char Tools,方便的字符编码转换小工具

    工作关系,常有字符编码转换方面的需要,写了这个小工具 Char Tools是一款方便的字符编码转换小工具,基于.Net Framework 2.0 Winform开发 主要功能 URL编码:URLEn ...

  9. 编码问题 php字符编码转换类

    各种平台和软件打开显示的编码问题,需要使用不同的编码,根据我们不同的需求. php 字符编码转换类,支持ANSI.Unicode.Unicode big endian.UTF-8.UTF-8+Bom ...

随机推荐

  1. 【大数据系列】win10上安装hadoop开发环境

    为了方便采用了Cygwin模拟linux环境的方法 一.安装JDK以及下载hadoop hadoop官网下载hadoop http://hadoop.apache.org/releases.html  ...

  2. hihoCoder挑战赛28 题目3 : 树的方差

    题目3 : 树的方差 时间限制:20000ms 单点时限:1000ms 内存限制:256MB 描述 对于一棵 n 个点的带标号无根树,设 d[i] 为点 i 的度数. 定义一棵树的方差为数组 d[1. ...

  3. !important:element.style 覆盖样式问题

    问题: 浏览器F12看到是这个样子. 但是我设置的样式是这样子. #iframe_close { width:750px; } 无论怎么设置样式,都无法覆盖掉element.style的样式,widt ...

  4. 语音AT命令参考

    不知道 这AT指令是不是通用的,尝试过的给我个回复 语音命令 命令 描述 +FCLASS=8 进入语音模式.AT+FCLASS=8 将调制解调器置入语音模式.扩音电话和TAM模式包括在通用语音模式中, ...

  5. 使用COSBench工具对ceph s3接口进行压力测试

    一.COSBench安装 COSBench是Intel团队基于java开发,对云存储的测试工具,全称是Cloud object Storage Bench 吐槽下,貌似这套工具是intel上海团队开发 ...

  6. “找女神要QQ号码”——java篇

    题目就是这样的: 给了一串数字(不是QQ号码),根据下面规则可以找出QQ号码: 首先删除第一个数,紧接着将第二个数放到这串数字的末尾,再将第三个数删除,并将第四个数放到这串数字的末尾...... 如此 ...

  7. github使用密钥登录

    注册github之后 初次使用git的用户要使用git协议大概需要三个步骤: 一.生成密钥对 二.设置远程仓库(本文以github为例)上的公钥     一.生成密钥对 再window系统中可以通过x ...

  8. UVM/OVM中的factory【zz】

    原文地址:http://bbs.eetop.cn/viewthread.php?tid=452518&extra=&authorid=828160&page=1 在新的项目中再 ...

  9. 不同修饰符使用细节(java)

    常用来修饰类.方法.变量的修饰符如下 public 权限修饰符,公共访问, 类,方法,成员变量 protected 权限修饰符,受保护访问, 方法,成员变量 默认什么也不写 也是一种权限修饰符,默认访 ...

  10. Python数据分析必备Anaconda安装、快捷键、包安装

    Python数据分析必备: 1.Anaconda操作 Anaconda是一个用于科学计算的Python发行版,支持 Linux, Mac, Windows系统,提供了包管理与环境管理的功能,可以很方便 ...