Python: UTF8转换代码实例

这是生成Android联系人vcf文件时候,转UTF8编码的例子.

def Convert(s):  
    r=""
    for c in s:
        temp = hex(ord(c)).replace("0x","")
        if len(temp) == 1:
            temp='0'+temp
        r=r+"="+temp
    return "CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:"+r

原文地址:https://www.cnblogs.com/shinedream/p/2908194.html