file.py 文件源码

python
阅读 35 收藏 0 点赞 0 评论 0

项目:server 作者: viur-framework 项目源码 文件源码
def decodeFileName(self, name):
        # http://code.google.com/p/googleappengine/issues/detail?id=2749
        # Open since Sept. 2010, claimed to be fixed in Version 1.7.2 (September 18, 2012)
        # and still totally broken
        try:
            if name.startswith("=?"): #RFC 2047
                return unicode( email.Header.make_header(email.Header.decode_header(name + "\n")))
            elif "=" in name and not name.endswith("="): #Quoted Printable
                return decodestring(name.encode("ascii")).decode("UTF-8")
            else: #Maybe base64 encoded
                return b64decode(name.encode("ascii")).decode("UTF-8")
        except: #Sorry - I cant guess whats happend here
            if isinstance(name, str) and not isinstance(name, unicode):
                try:
                    return name.decode("UTF-8", "ignore")
                except:
                    pass

            return name
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号