def KoUserEnviron(startupEnvFileName=None):
    koEnviron = components.classes[ "@activestate.com/koUserEnviron;1"] \
                .createInstance(components.interfaces.koIUserEnviron)
    if startupEnvFileName:
        environ = UnwrapObject(koEnviron)
        environ.__init__(startupEnvFileName)
        current_encoding = locale.getlocale()[1]
        # For some reason this can be the value 'None' when running in
        # the pyxpcom test suite, so fall back to the expected default
        # platform encoding.
        if not current_encoding:
            if sys.platform.startswith('win'):
                current_encoding = 'mbcs'
            elif sys.platform.startswith('darwin'):
                current_encoding = 'mac-roman'
            elif sys.platform.startswith('linux'):
                current_encoding = 'utf-8'
        environ.startupEnvironEncoding = current_encoding

    return koEnviron
def KoUserEnviron(startupEnvFileName=None):
    koEnviron = components.classes[ "@activestate.com/koUserEnviron;1"] \
                .createInstance(components.interfaces.koIUserEnviron)
    if startupEnvFileName:
        environ = UnwrapObject(koEnviron)
        environ.__init__(startupEnvFileName)
        current_encoding = locale.getlocale()[1]
        # For some reason this can be the value 'None' when running in
        # the pyxpcom test suite, so fall back to the expected default
        # platform encoding.
        if not current_encoding:
            if sys.platform.startswith('win'):
                current_encoding = 'mbcs'
            elif sys.platform.startswith('darwin'):
                current_encoding = 'mac-roman'
            elif sys.platform.startswith('linux'):
                current_encoding = 'utf-8'
        environ.startupEnvironEncoding = current_encoding

    return koEnviron