[comp.sys.mac.programmer] SANE and International Utilities

ralph@computing-maths.cardiff.ac.uk (Ralph Martin) (10/30/89)

The Apple Numerics Manual says that Str2Num for converting strings to numbers
looks for "." as the decimal point character, while the International utilities
as described in Inside Mac allow for characters other than "." to be used for
decimal point in coutries like Italy. So, does this mean that to be friendly to
foreigners, I should not use Str2Num, but I must write my own replacement for
it? And if so, why doesnt Str2Num take this into account!

Ralph

earleh@eleazar.dartmouth.edu (Earle R. Horton) (10/31/89)

In article <873@cf-cm.UUCP> ralph@computing-maths.cardiff.ac.uk
	(Ralph Martin) writes:

>The Apple Numerics Manual says that Str2Num for converting strings to
>numbers looks for "." as the decimal point character, while the
>International utilities as described in Inside Mac allow for
>characters other than "." to be used for decimal point in coutries
>like Italy. So, does this mean that to be friendly to foreigners, I
>should not use Str2Num, but I must write my own replacement for it?
>And if so, why doesnt Str2Num take this into account!

The Script Manager version 2.0 contains new number routines which may
be used to read and write numbers in a locality-independent fashion.
These won't work unless the system version is new enough and the
routines are actually installed, of course.  I have looked at the
manual, and it looks as if Apple is seriously trying to provide an
all-purpose token converter to make international programming easier.
It also looks as if it might take a considerable investment of time
to gain some familiarity with the package, however.  (You know how
Apple is.)

If you don't want to have to depend on the new Script Manager's
presence, then you can use the International Utilities Package to get
the local decimal point.  Something like this might work:

char ldecpt;

	ldecpt = (**IUGetIntl(0)).decimalPt;

You can then parse numbers by reading them through a filter that
converts the local decimal point to '.', then feeds the filtered
result to SANE.  Don't forget the thousands separator!

Earle R. Horton