Re: Decimal separator from python to C
niki <[email protected]> Wed, 28 Mar 2012 10:31:51 +0300
| Newsgroups | gmane.comp.python.ctypes |
|---|---|
| Message-ID | <[email protected]> |
On 28.03.2012 03:04, M. wrote: > Hey, > > 2012/3/27 niki<[email protected]>: >> On 26.03.2012 23:32, M. wrote: >>> >>> Hi all, >>> >>> I'm using ctypes as a wrapper from a Pyside program to a C program. >>> Everything goes smoothly till I have to pass values to the C function. >>> The C function receive the values correctly when using >>> ctypes.c_double(), but the separator _inside_ the C code changed from >>> . to , and that is REALLY weird. Printing the data from python it >>> shows that is a float, and inside the C code everything is declared >>> accordingly. printf inside the C code shows a comma , as the >>> separator, while a C code compiled using the same compiler on the same >>> system shows period . as the separator. Any clues? My locale is >>> pt_BR-UTF-8. >> >> >> Python sets locale as requested by user/os e.g. "pt_BR-UTF-8". >> Try to set it back to "C". > > I'll try, but a C program with the same locale defined on the system > gives the correct output. And a standard python program represents > floating point variables using a period. How come ctypes would pass > the variables to the C code using a comma? ctypes.c_double is binary number and has no ascii content. Minimal C programs usually don't set locale. Niki ------------------------------------------------------------------------------ This SF email is sponsosred by: Try Windows Azure free for 90 days Click Here http://p.sf.net/sfu/sfd2d-msazure