[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Locale breaks scanf()



On Thu, Apr 22, 1999 at 07:25:43PM +0200, Andreas Tille wrote:
> Is there any solution to use '.' in any case as separator??

Yes.  There are two of them:

  1) Set the appropriate locale category to C.
  2) Don't use the library functions to parse a defined
     input format.  A self-cooked string->double converter
     is not too hard to write and has the exact semantics
     you want.

> I consider this behaviour of locale as insane.

Don't blame the library for not being the exact thing you want it to be.

It is quite convenient for the user that they can use their local
conventions when giving input.  You just shouldn't use the locale-affected
routines to parse specially formatted file. (For maximum portability, you
should even use 32 in place of ' ':-)

-- 
Antti-Juhani Kaijanaho A7 <gaia@iki.fi> ** <URL:http://www.iki.fi/gaia/> **

                       The FAQ is your friend.
                            Trust the FAQ.


Reply to: