Utils.py 文件源码

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

项目:rl-bareos 作者: kjetilho 项目源码 文件源码
def deunicodise(string, encoding = None, errors = "replace"):
    """
    Convert unicode 'string' to <type str>, by default replacing
    all invalid characters with '?' or raise an exception.
    """

    if not encoding:
        encoding = Config.Config().encoding

    if type(string) != unicode:
        return str(string)
    debug("DeUnicodising %r using %s" % (string, encoding))
    try:
        return string.encode(encoding, errors)
    except UnicodeEncodeError:
        raise UnicodeEncodeError("Conversion from unicode failed: %r" % string)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号