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. 原生js--userData

    userData是IE5及其以上浏览器支持的一种客户端存储方式,它通过在document元素后面附加一个专属的元素来实现. 对userData的封装: /** * IE userdata封装 */fu ...

  2. MIME类型列表

    A Multipurpose Internet Mail Extensions (MIME) type is a standard that indicates the nature and form ...

  3. java(3) 面向对象

    1.super关键字 * 使用super关键字调用父类的成员变量和成员方法.具体格式: super.成员变量 super.成员方法([参数1,参数2...]) * 使用super关键字调用父类的构造方 ...

  4. Elasticsearch学习之深入搜索六 --- 平衡搜索结果的精准率和召回率

    1. 召回率和精准度 比如你搜索一个java spark,总共有100个doc,能返回多少个doc作为结果,就是召回率,recall 精准度,比如你搜索一个java spark,能不能尽可能让包含ja ...

  5. 题目1447:最短路(Floyd算法)

    题目链接:http://ac.jobdu.com/problem.php?pid=1447 详解链接:https://github.com/zpfbuaa/JobduInCPlusPlus 参考代码: ...

  6. linux下php的一些问题

    一.Loaded Configuration File  none Configuration File (php.ini) Path /data/service/php/etc 在etc目录下有ph ...

  7. vs 的git插件

    在vs2013上Tfs提供的git管理完全无法理解他的管理方式,还是 Git Source Control Provider 好用用. 下载地址: [http://gitscc.codeplex.co ...

  8. python中的null值

    在一个没有接口文档的自动化测试中,只能通过抓包及查日志查看发送的信息,其中有一个接口发送的信息如下: enable_snapshot": true, "new_size" ...

  9. 170817、Nginx详细配置

    Nginx能做什么 nginx主要是做转发,当然也可以做静态资源文件缓存,做转发的时候,比如你有几个url,可以统一通过走nginx,然后通过nginx转发到不同的url上 1.反向代理 反向代理应该 ...

  10. on("submit",)

    和$("form").submit(function(){    alert("提交");});都只适用于form表单元素的jquery对象