(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'
Return the unicode representation of the supplied value:
Return the unicode representation of the supplied value :
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:]
    else:
        try:
            return unicode(value)
        except UnicodeDecodeError:
            return unicode(str(value), errors="ignore")
def getUnicode ( value , encoding = None , noneToNull = False ) : 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 : ] else : try : return unicode ( value ) except UnicodeDecodeError : return unicode ( str ( value ) , errors = "ignore" )