示例#1
0
                                  BIG5.decode,
                                  streamreader=BIG5.streamreader,
                                  streamwriter=BIG5.streamwriter,
                                  incrementalencoder=BIG5.incrementalencoder,
                                  incrementaldecoder=BIG5.incrementaldecoder,
                                  name='cn-big5')
    except LookupError:
        # we'll have to do without cn-big5
        pass

try:
    APPLESYMBOL = codecs.lookup('apple-symbol')
    pass
except LookupError:
    import pyslet.unicode_apple_symbol as symbol
    APPLESYMBOL = symbol.getregentry()


def QTICodecSearch(name):
    if name.lower() == "cn-big5" and CNBIG5:
        return CNBIG5
    elif name.lower() == "apple-symbol":
        return APPLESYMBOL


def RegisterCodecs():
    """The example files that are distributed with the QTI specification contain
    a set of Chinese examples encoded using big5.  However, the xml declarations
    on these files refer to the charset as "CN-BIG5" and this causes errors when
    parsing them as this is a non-standard way of refering to big5.
示例#2
0
    CNBIG5 = None
    try:
        BIG5 = codecs.lookup('big5')
        CNBIG5 = codecs.CodecInfo(BIG5.encode, BIG5.decode, streamreader=BIG5.streamreader,
                                  streamwriter=BIG5.streamwriter, incrementalencoder=BIG5.incrementalencoder,
                                  incrementaldecoder=BIG5.incrementaldecoder, name='cn-big5')
    except LookupError:
        # we'll have to do without cn-big5
        pass

try:
    APPLESYMBOL = codecs.lookup('apple-symbol')
    pass
except LookupError:
    import pyslet.unicode_apple_symbol as symbol
    APPLESYMBOL = symbol.getregentry()


def QTICodecSearch(name):
    if name.lower() == "cn-big5" and CNBIG5:
        return CNBIG5
    elif name.lower() == "apple-symbol":
        return APPLESYMBOL


def RegisterCodecs():
    """The example files that are distributed with the QTI specification contain
    a set of Chinese examples encoded using big5.  However, the xml declarations
    on these files refer to the charset as "CN-BIG5" and this causes errors when
    parsing them as this is a non-standard way of refering to big5.