Locale-sensitive list separator under Windows
list.adam at twardoch.com
Thu Jan 16 02:31:34 CET 2003
"Martin v. Löwis" <martin at v.loewis.de> wrote in message
news:b051kv$230$00$1 at news.t-online.com...
> Adam Twardoch wrote:
> > How can make Python resolve the locale-sensitive list separator under
> > Windows? I mean the one that is set under Control Panel / Regional
> > Numbers / List separator.
> Is locale.localeconv()['thousands_sep'] what you want?
No, unfortunately not. The thousands_sep is what the Windows API
GetLocaleInfoW function returns if the LCType LOCALE_STHOUSAND = &HF is
called. I need the value that is returned when the LCType LOCALE_SLIST = &HC
is called. Typically, it's a comma (in English locales) or semicolon (in
German or Polish locale). These are used to separate text entries in lists
such as e-mail address lists.
BTW: The code to do what I need in Visual Basic would be following:
' Start here
Option Compare Text
Private Declare Function GetLocaleInfoW Lib "kernel32" _
(ByVal LCID As Long, ByVal LCType As LCTypeEnum, _
ByVal lpData As Long, ByVal cchData As Integer) As Integer
Public Function GetLocaleInfoC(Locale As Long, _
LCType As LCTypeEnum) As String
Dim stBuff As String
Dim rc As Long
stBuff = String$(255, vbNullChar)
rc = GetLocaleInfoW(Locale, LCType, StrPtr(stBuff), Len(stBuff))
If (rc > 0) Then
GetLocaleInfoC = StFromSz(stBuff)
' End here
Now, who could help me translate this into Python? I have no idea how you
call a kernel32.dll function from within Python (or the Python win32all
Thanks in advance!
More information about the Python-list