Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Windows XP - Environment variable - Unicode

Reply
Thread Tools

Re: Windows XP - Environment variable - Unicode

 
 
Alan Kennedy
Guest
Posts: n/a
 
      07-11-2003
"sebastien.hugues" wrote:

> Actually the issue is that this variable is
> set by the system itself. It is not accessible from the control panel.
> In the other hand, i don't use any terminal.
>
> So the question is how to get the default encoding of the system ?
> I was looking for a while in win32api documentation, msdn and
> Google but i didn't get nothing.


This page from MSDN explains about how locales are handled for
different users.

http://msdn.microsoft.com/msdnnews/2.../Spotlight.asp

Quoting: (for the archives, since MS are guaranteed to make the above
link break sometime)

"""
The System Default Locale

The system default locale acts as an ANSI simulation layer. It
determines the ANSI code page that the system uses when running a
non-Unicode application. For example, if the system default locale is
Japanese, then to a non-Unicode application the operating system will
behave similarly to a Japanese operating system, fully able to support
non-Unicode Japanese applications, but unable to support
non-Japanese-compatible applications (such as a Korean non-Unicode
app). The operating system uses the Japanese code page 932 when
ANSI-Unicode translation is needed. So, the system default locale
determines whether or not your non-Unicode application will run.

The system default locale is set at installation, but can be changed
in the Control Panel. To get the current system default locale, call
the GetSystemDefaultLCID function.

The User Locale and the Thread Locale

The user locale and the thread locale determine which settings are
used for formatting dates, times, currency, and large numbers as a
default for each user. The user locale and the thread locale also
determine the sort order for sorting text. The thread locale can be
set separately for each thread. When the thread locale and the user
locale are different, the thread locale overrides the user locale.
For example, even though your app is English and the system default
locale is English, as long as the user locale is Spanish (and you did
not set the thread locale specifically), your strings will be sorted
by the Spanish sorting order. If you need your app's numbers,
currency, or sorting to be done in a certain locale, make sure that
you set the thread locale explicitly by calling the SetThreadLocale
function.
When each thread starts, the thread locale defaults to the user
locale. The user locale defaults to the locale that matches the
language of the localized system. To get the user locale, call the
GetUserDefaultLCID function. Call the GetThreadLocale function to get
the calling thread locale.
"""

I'm not sure if the env var you're looking at is set in the system or
user default locale, so probably best to try both:-

systemdefaultlcid = win32api.GetSystemDefaultLCID()
userdefaultlcid = win32api.GetUserDefaultLCID()

http://aspn.activestate.com/ASPN/Pyt...ngID_meth.html

Now, as for how to turn an LCID into a character set name, I don't
know the answer to that one

Here's a q&d hack for getting the user default character set, through
an internet explorer COM object.

from win32com.client import Dispatch
htmldoc = Dispatch("htmlfile")
htmldoc.writeln("<h1>any old stuff</h1>")
print htmldoc.defaultCharset

HTH,

--
alan kennedy
-----------------------------------------------------
check http headers here: http://xhaus.com/headers
email alan: http://xhaus.com/mailto/alan
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
70-284 Lab Environment, Need Virtual Environment brooklynbridge508@hotmail.com MCSA 4 05-02-2007 09:49 AM
Setting an environment variable from another environment variable marcwentink@hotmail.com Java 5 04-04-2007 10:39 PM
Setting Windows environment variable Pavel Ledin Ruby 2 09-20-2006 10:01 AM
Set Windows Environment Variable Fuzzyman Python 6 03-30-2006 07:19 PM
Windows XP - Environment variable - Unicode sebastien.hugues Python 8 07-13-2003 06:38 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57