中文unicode范围 : [\u4e00-\u9fa5]  

普通字符串可以用多种方式编码成Unicode字符串,具体要看你究竟选择了哪种编码:
unicodestring = u"Hello world" 
# 将Unicode转化为普通Python字符串:"encode"

utf8string = unicodestring.encode("utf-8")
asciistring = unicodestring.encode("ascii")
isostring = unicodestring.encode("ISO-8859-1")
utf16string = unicodestring.encode("utf-16")

# 将普通Python字符串转化为Unicode:"decode"

plainstring1 = unicode(utf8string, "utf-8")
plainstring2 = unicode(asciistring, "ascii")
plainstring3 = unicode(isostring, "ISO-8859-1")
plainstring4 = unicode(utf16string, "utf-16")
assert plainstring1 == plainstring2 == plainstring3 == plainstring4

中文unicode范围及unicode编解码的更多相关文章

  1. 字符编解码的故事–ASCII,ANSI,Unicode,Utf-8区别(转)

    很久很久以前,有一群人,他们决定用8个可以开合的晶体管来组合成不同的状态,以表示世界上的万物.他们认为8个开关状态作为原子单位很好,于是他们把这称为”字节”. 再后来,他们又做了一些可以处理这些字节的 ...

  2. python中的字符串编码问题——4.unicode编解码(以实际工作中遇到的韩文编码为例)

    韩文unicode编解码  问题是这样,工作中遇到有韩文数据出现乱码,说是unicode码. 类似这样: id name 323 52186863 149 63637538 314 65516863 ...

  3. C#字符串Unicode转义序列编解码

    C#字符串Unicode转义序列编解码 在开发过程中时常会遇到"\Uxxxx"格式表示的字符,实际上"xxxx"是字符的Unicode码的十六进制表示方式.这种 ...

  4. 中文转换成Unicode编码 和 Unicode编码转换为中文

    前几天,遇到一个问题,就是在浏览器地址栏传递中文时,出现乱码,考虑了一下,解决方式有很多,我还是采用了转换编码的方式,将中文转换为Unicode编码,然后再解码成中文,以下是实现的过程,非常简单! p ...

  5. 中文字符串转换为十六进制Unicode编码字符串

    package my.unicode; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Uni ...

  6. 中文转unicode,中文转bytes,unicode转bytes java实现

    utf-8 utf-8格式的中文由三位字节组成. UTF-8的编码规则很简单,只有二条: 1)对于单字节的符号,字节的第一位设为0,后面7位为这个符号的unicode码.因此对于英语字母,UTF-8编 ...

  7. 解决JSON.stringify()自动将中文转译成unicode的方法

    最近在工作中,发现在IE8下JSON.stringify()自动将中文转译为unicode编码,原本选择的中文字符,传到后台变为了unicode编码,即\u****的形式.查找资料后发现,与标准的JS ...

  8. java对含有中文的字符串进行Unicode编码

    public class MyUtil { public static void main(String[] args) throws Exception { String s = "a中a ...

  9. unicode,ansi,utf-8,unicode big endian编码的区别

    知乎--http://www.zhihu.com/question/23374078 http://wenku.baidu.com/view/cb9fe505cc17552707220865.html ...

  10. 【转】Java web 编解码

    几种常见的编码格式 为什么要编码 不知道大家有没有想过一个问题,那就是为什么要编码?我们能不能不编码?要回答这个问题必须要回到计算机是如何表示我们人类能够理解的符号的,这些符号也就是我们人类使用的语言 ...

随机推荐

  1. T恤

    64%聚酯纤维+36%纯棉比较舒服,洗了不易变形,普通纯棉易变形

  2. XML序列化中含有List的情况,序列化到根节点下一层

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.X ...

  3. 在同步中调用异步方法[.net 4.5]

    using System; using System.Threading; using System.Threading.Tasks; namespace Microsoft.AspNet.Ident ...

  4. python-ansible

    http://sofar.blog.51cto.com/353572/1579894 http://www.aikaiyuan.com/6299.html http://docs.ansible.co ...

  5. unity, 查看.anim中的动画曲线(和帧)

    在场景里建一个gameObject,添加一个Animation组件,将.anim文件添加到Animation组件的Animations中,然后在Animation组件面板中选中.anim,然后 菜单- ...

  6. nginx设置不使用缓存 add_header Cache-Control no-cache

    nginx设置不使用缓存 server { listen 443; #域名 server_name www.dev.163.com; #字符集 charset utf-8; ssl on; ssl_c ...

  7. ubuntu 使用adb shell命令识别android设备

    ubuntu 使用adb shell命令配置 在ubuntu下使用adb 命令识别Android设备需配置adb_usb.ini 文件 文件路径:  ~/.android/ ,若不存在创建该文件. a ...

  8. .Net分布式缓存应用实例:Couchbase

    转自:http://www.cnblogs.com/wu-jian Couchbase概述 Couchbase最早叫Membase,是由Memcached项目组的一些头目另立的山头. 2011年与Co ...

  9. 微信公众平台Php版php开发(转)

    http://www.1990c.com/?p=932 近在做微信公众平台开发,一口气写了二十几个功能,挺有意思的-  今天来分享一下开发经验~微信公众平台提供的接口很简单,先看看消息交互流程:  说 ...

  10. OC-字典

    1.所有的key都是一个字符串,键 值是成对出现的.且都不能为空,非要为空要使用NSnull.字典是通过key来存取值的,key valu必须成对出场 2.字典是有键-值的数据组合,通过key查找对于 ...