Locale-sensitive list separator under Windows
Adam Twardoch
list.adam at twardoch.com
Wed Jan 15 20:31:34 EST 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
Options /
> > 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.
Anybody else?
BTW: The code to do what I need in Visual Basic would be following:
' Start here
Option Compare Text
Option Explicit
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 If
End Function
Sub Main()
MsgBox(GetLocaleInfoC(1024,&HC)
End Sub
' 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
extensions).
Thanks in advance!
Adam
More information about the Python-list
mailing list