At 12:00am -0800 01-02-05, Palm Developer Forum digest wrote:
> >> I'm attempting to use StrPrintF to return a string from UInt32,
> >> formatted with commas, (e.g. 1234567 should return "1,234,567") but
> >> can't seem to come up with a way to do it. Has anyone done this or
> >> does anyone know of a easy/good way of doing it?
> >
> >There's a "commafier" in Snippets: www.snippets.org
>There's also a StrLocalizeNumber in the String Manager.
> > > Of course, also be aware that comma is not the appropriate separator in
>all
> > > locales. (ie, "1.234.567,12" in many places).
> >
> > ie: Sweden, Finland, Denmark, Norway :P
To convert a UInt32 into a comma-formatted string, you
1a. Convert the value to a string using StrIToA, then insert commas
every three digits, or
1b. Use something like the commafier code at www.snippets.org to
convert & insert commas.
2. Get the user's number format by calling SysGetPreference(prefNumberFormat).
3. Pass the returned NumberFormatType to LocGetNumberSeparators() to
get the thousands and decimal separator characters.
4. Call StrLocalizeNumber() to convert the ',' and '.' characters in
the string from step 1 into the appropriate characters returned in
step 3.
-- Ken
Ken Krugler
TransPac Software, Inc.
<http://www.transpac.com>
+1 530-470-9200
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/