当前位置: 首页>>代码示例>>Python>>正文


Python settings.INVALID_UNICODE_CHAR_FORMAT属性代码示例

本文整理汇总了Python中lib.core.settings.INVALID_UNICODE_CHAR_FORMAT属性的典型用法代码示例。如果您正苦于以下问题:Python settings.INVALID_UNICODE_CHAR_FORMAT属性的具体用法?Python settings.INVALID_UNICODE_CHAR_FORMAT怎么用?Python settings.INVALID_UNICODE_CHAR_FORMAT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在lib.core.settings的用法示例。


在下文中一共展示了settings.INVALID_UNICODE_CHAR_FORMAT属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getUnicode

# 需要导入模块: from lib.core import settings [as 别名]
# 或者: from lib.core.settings import INVALID_UNICODE_CHAR_FORMAT [as 别名]
def getUnicode(value, encoding=None, noneToNull=False):
    """
    Return the unicode representation of the supplied value:

    >>> getUnicode(u'test')
    u'test'
    >>> getUnicode('test')
    u'test'
    >>> getUnicode(1)
    u'1'
    """

    if noneToNull and value is None:
        return NULL

    if isListLike(value):
        value = list(getUnicode(_, encoding, noneToNull) for _ in value)
        return value

    if isinstance(value, unicode):
        return value
    elif isinstance(value, basestring):
        while True:
            try:
                return unicode(value, encoding or (kb.get("pageEncoding") if kb.get("originalPage") else None) or UNICODE_ENCODING)
            except UnicodeDecodeError, ex:
                try:
                    return unicode(value, UNICODE_ENCODING)
                except:
                    value = value[:ex.start] + "".join(INVALID_UNICODE_CHAR_FORMAT % ord(_) for _ in value[ex.start:ex.end]) + value[ex.end:] 
开发者ID:krintoxi,项目名称:NoobSec-Toolkit,代码行数:32,代码来源:common.py

示例2: getUnicode

# 需要导入模块: from lib.core import settings [as 别名]
# 或者: from lib.core.settings import INVALID_UNICODE_CHAR_FORMAT [as 别名]
def getUnicode(value, encoding=None, noneToNull=False):
    """
    Return the unicode representation of the supplied value:

    >>> getUnicode(u'test')
    u'test'
    >>> getUnicode('test')
    u'test'
    >>> getUnicode(1)
    u'1'
    """

    if noneToNull and value is None:
        return "NULL"

    if isinstance(value, unicode):
        return value
    elif isinstance(value, basestring):
        while True:
            try:
                return unicode(value, encoding or "utf8")
            except UnicodeDecodeError, ex:
                try:
                    return unicode(value, "utf8")
                except:
                    value = value[:ex.start] + "".join(INVALID_UNICODE_CHAR_FORMAT % ord(_) for _ in value[ex.start:ex.end]) + value[ex.end:] 
开发者ID:w-digital-scanner,项目名称:w9scan,代码行数:28,代码来源:common.py

示例3: getUnicode

# 需要导入模块: from lib.core import settings [as 别名]
# 或者: from lib.core.settings import INVALID_UNICODE_CHAR_FORMAT [as 别名]
def getUnicode(value, encoding=None, noneToNull=False):
    """
    Return the unicode representation of the supplied value:

    >>> getUnicode(u'test')
    u'test'
    >>> getUnicode('test')
    u'test'
    >>> getUnicode(1)
    u'1'
    """

    if noneToNull and value is None:
        return u'NULL'

    if isListLike(value):
        value = list(getUnicode(_, encoding, noneToNull) for _ in value)
        return value

    if isinstance(value, unicode):
        return value
    elif isinstance(value, basestring):
        while True:
            try:
                return unicode(value, encoding or UNICODE_ENCODING)
            except UnicodeDecodeError, ex:
                try:
                    return unicode(value, UNICODE_ENCODING)
                except:
                    value = value[:ex.start] + "".join(INVALID_UNICODE_CHAR_FORMAT % ord(_) for _ in value[ex.start:ex.end]) + value[ex.end:] 
开发者ID:zer0yu,项目名称:ZEROScan,代码行数:32,代码来源:common.py

示例4: getUnicode

# 需要导入模块: from lib.core import settings [as 别名]
# 或者: from lib.core.settings import INVALID_UNICODE_CHAR_FORMAT [as 别名]
def getUnicode(value, encoding=None, noneToNull=False):
    """
    Return the unicode representation of the supplied value:

    >>> getUnicode(u'test')
    u'test'
    >>> getUnicode('test')
    u'test'
    >>> getUnicode(1)
    u'1'
    """

    if noneToNull and value is None:
        return NULL

    if isinstance(value, unicode):
        return value
    elif isinstance(value, basestring):
        while True:
            try:
                return unicode(value, encoding or (kb.get("pageEncoding") if kb.get("originalPage") else None) or UNICODE_ENCODING)
            except UnicodeDecodeError, ex:
                try:
                    return unicode(value, UNICODE_ENCODING)
                except:
                    value = value[:ex.start] + "".join(INVALID_UNICODE_CHAR_FORMAT % ord(_) for _ in value[ex.start:ex.end]) + value[ex.end:] 
开发者ID:sabri-zaki,项目名称:EasY_HaCk,代码行数:28,代码来源:common.py


注:本文中的lib.core.settings.INVALID_UNICODE_CHAR_FORMAT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。