Python中的Unicode在Delphi如何还原成Gb2312?
已知Python 中:
s = unicode("测试", "gb2312")
s = u'\u6d4b\u8bd5'
print s
测试
在Delphi里面如何将\u6d4b\u8bd5这样的还原成Gb2312的汉字呢?
找到个方法
function UniCode2GB(S : String):String;
Var
I: Integer;
begin
I := Length(S);
while I >=4 do
begin
try
Result :=WideChar(StrToInt('$'+S[I-3]+S[I-2]+S[I-1]+S[I]))+ Result;
except end;
I := I - 4;
end;
end;
相关问答:
最近用python写一个程序,总是异常退出,但是却没法用try..except来捕捉
由于没法发图片,所以把相关的信息打印出来
异常的信息大致如下:
python.exe遇到问题需要关闭。我们对此引起的不便表示抱歉 ......
python如何解压缩.Z的文件啊,在windows系统环境下
Q7Z 是一款基于 Qt4 的 7z 压缩工具
http://code.google.com/p/k7z/
开源的
http://sourceforge.net/projects/k7z/
LS的能具体说一说吗?
......
喜欢Python的朋友请进.
详细信息请查看:
http://blog.csdn.net/lgg201/archive/2009/10/08/4643635.aspx
Let's-python-系列视频发布专贴 收藏
视频较早的时候就说是要录了, 这一周录了 ......
如果一段代码
Python code:
#!/usr/bin/python2.5
from urllib2 import Request,urlopen,URLError
def check():
req = Request('http://www.google.com')
try:
res = urlopen(req).read()
......