Locale>>groupingSeparator

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Locale>>groupingSeparator

Günther Schmidt
Hi,

does anybody know whether there is a grouping separator in Windows just
like there is a decimal separator?.

I try to add this method to the Locale class, but don't know the
constant off hand.

The motivation behind this is to modify Ian's CurrencyToText converter
so I can use German decimal and grouping separators.


Günther


Reply | Threaded
Open this post in threaded view
|

Re: Locale>>groupingSeparator

Ian Bartholomew-21
Günther,

> The motivation behind this is to modify Ian's CurrencyToText converter so
> I can use German decimal and grouping separators.

Can't help much with the locale question but looking at the CurrencyToText
goodie it won't be too difficult to factor out the decimal separator, and
maybe the number of characters between separators,  into settable instVars.
It looks like a good idea so I'll have a go at that later and post an
updated goodie - possibly tomorrow though.

Are there any other settings or characters that should be more flexible?.
I'm not very au fait with the diffierent formats used by forig^H^H^H^H^H
other cultures.

Thanks for the suggestion - although you probably didn't intend it as one
:-)

--
Ian

Use the Reply-To address to contact me (limited validity).
Mail sent to the From address is ignored.


Reply | Threaded
Open this post in threaded view
|

Re: Locale>>groupingSeparator

Günther Schmidt
In reply to this post by Günther Schmidt
Ian,

thanks!

Well I think it'd be nice if we could add Local>>groupingSeparator
though, I believe windows has that somewhere.

Günther

Ian Bartholomew schrieb:

> Günther,
>
>> The motivation behind this is to modify Ian's CurrencyToText converter so
>> I can use German decimal and grouping separators.
>
> Can't help much with the locale question but looking at the CurrencyToText
> goodie it won't be too difficult to factor out the decimal separator, and
> maybe the number of characters between separators,  into settable instVars.
> It looks like a good idea so I'll have a go at that later and post an
> updated goodie - possibly tomorrow though.
>
> Are there any other settings or characters that should be more flexible?.
> I'm not very au fait with the diffierent formats used by forig^H^H^H^H^H
> other cultures.
>
> Thanks for the suggestion - although you probably didn't intend it as one
> :-)
>


Reply | Threaded
Open this post in threaded view
|

Re: Locale>>groupingSeparator

Ian Bartholomew-21
In reply to this post by Günther Schmidt
I wrote

> It looks like a good idea so I'll have a go at that later and post an
> updated goodie - possibly tomorrow though.


There's an updated Currency to Text package now available from my updates
page

http://www.idb.me.uk/files/updates.html

It now has two more configurable options

integerSeparator - a String that is used as the separator between blocks of
numbers in Integer separation

integerSeparation - an Integer specifying the number of characters in each
block

I've also changed the name of the #commas option, it's now called
#useSeparators.  You can still use #commas but it is deprecated.

It's only had a quick test.  I'll check it out again tomorrow and then
update it in my goodies package.

--
Ian

Use the Reply-To address to contact me (limited validity).
Mail sent to the From address is ignored.


Reply | Threaded
Open this post in threaded view
|

Re: Locale>>groupingSeparator

Chris Uppal-3
In reply to this post by Günther Schmidt
Günther,

> does anybody know whether there is a grouping separator in Windows just
> like there is a decimal separator?.

Yes there is.  There's rather a lot of stuff in Windows locale (If you are
interested search MSDN for NUMBERFMT), and only a little of it is exposed via
the Locale class[*].  The grouping separator can be extracted by adding a new
method to Locale like:

==============
thousandsSeparator
    "Answer the thousands separator String used in the receiver locale.
    Implementation Note: This ought to be cached."
#CUadded.

    ^ self getInfo: LOCALE_STHOUSAND.
==============

where LOCALE_STHOUSAND is 15.

One warning: Windows locales distinguish between numbers used as generic
numbers, and numbers used for currency.  The above is the generic separator;
can't remember what the currency version is, or even whether there is a
separate version in this case.

Another warning: using ',' and '.' raw isn't really using the localisation
information properly (apparently some locales group digits in fours, and there
are several other cultural variations in formatting).  But I suspect you don't
need the full richness for your purposes here.

    -- chris

([*] I have a wrapper for more of that stuff, but since it so far only does
numbers (not currency), doesn't /parse/ localised numbers, and doesn't
integrate with the Converter architecture, I haven't released it yet.  But feel
free to drop me a line if you'd like a pre-release copy.)