Пример #1
0
def get_console_cp(space):
    """get_console_cp()

    Return the console and console output code page (windows only)
    """
    from rpython.rlib import rwin32  # Windows only
    return space.newtuple([
        space.newtext('cp%d' % rwin32.GetConsoleCP()),
        space.newtext('cp%d' % rwin32.GetConsoleOutputCP()),
    ])
Пример #2
0
def device_encoding(space, fd):
    """device_encoding(fd) -> str

    Return a string describing the encoding of the device if the output
    is a terminal; else return None.
    """
    if not (rposix.is_valid_fd(fd) and os.isatty(fd)):
        return space.w_None
    if _WIN32:
        if fd == 0:
            return space.wrap('cp%d' % rwin32.GetConsoleCP())
        if fd in (1, 2):
            return space.wrap('cp%d' % rwin32.GetConsoleOutputCP())
    from rpython.rlib import rlocale
    if rlocale.HAVE_LANGINFO:
        codeset = rlocale.nl_langinfo(rlocale.CODESET)
        if codeset:
            return space.wrap(codeset)
    return space.w_None
Пример #3
0
def get_console_cp(space):
    from rpython.rlib import rwin32  # Windows only
    return space.newtuple([
        space.newtext('cp%d' % rwin32.GetConsoleCP()),
        space.newtext('cp%d' % rwin32.GetConsoleOutputCP()),
    ])