os.system and unicode arguments fail on Win32

Tim Daneliuk tundra at tundraware.com
Tue Jan 21 20:00:07 EST 2003


Martin v. Löwis wrote:
> Tim Daneliuk <tundra at tundraware.com> writes:
> 
<SNIP>

> This will change in Python 2.3. In many cases, Python 2.2 will also
> accept Unicode strings in file system API on Windows. For Python 2.3,
> and NT+, all Unicode strings are usable as file names.
> 
> This still does not include os.system, or environment variables.

What is the restiction here that prevents 2.3 from doing things
the same way with these portions of the OS.

Incidentally, it seem strange to me that Win32 is inherently
a unicode environment but os.system (which presumably mapps
to some Win32 API) has trouble with unicode strings...-

> 
>>Is there a way to "depromote" a unicode string into a byte string that
>>the os calls can live with, or am I forced to figure out a low-level
>>system call (via win32all, I guess) which *should* be able to handle
>>this case.
> 
> 
> Sure. Just invoke .encode(native encoding) on the Unicode object, to
> obtain a byte string.
> 
> On Windows, using "mbcs" as the native encoding is correct in most
> cases.

Do you happen to have a URL (or better still, a programmatic method)
whereby I might determine the native encodings for various systems?

Vielen Danke ;) for your extensive help in these unicode matters over
the past couple of days...


-- 
------------------------------------------------------------------------------
Tim Daneliuk
tundra at tundraware.com





More information about the Python-list mailing list