Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2012-06

Currency symbol wrong location

8 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Leonardo M. Ramé

Hi, I want to format a float number to currency. To do this, I use the Format function using the %m format, as this:

Format('%m', [123.25]);

I'm using Ubuntu 12.04 and my regional settings at configured to display "$ 1234.25", but I'm getting "123.25$", why is the money symbol at the right side, instead of using the regional setting?.

Leonardo M. Ramé
http://leonardorame.blogspot.com 

Michael Van Canneyt
to Leonardo M. Ramé
Leonardo M. Ramé wrote 5 lines
Hi, I want to format a float number to currency. To do this, I use the Format function using the %m format, as this: Format('%m', [123.25]); I'm using Ubuntu 12.04 and my regional settings at configured to display "$ 1234.25", but I'm getting "123.25$", why is the money symbol at the right side, instead of using the regional setting?.

Did you use the CLocale unit ?

Michael.

Leonardo M. Ramé
to Michael Van Canneyt

----- Original Message -----

Show quoted text 26 lines
From: Michael Van Canneyt To: Leonardo M. Ramé ; FPC-Pascal users discussions Cc: Sent: Saturday, June 9, 2012 11:59 AM Subject: Re: [fpc-pascal] Currency symbol wrong location On Sat, 9 Jun 2012, Leonardo M. Ramé wrote: > Hi, I want to format a float number to currency. To do this, I use the Format function using the %m format, as this: > > Format('%m', [123.25]); > > I'm using Ubuntu 12.04 and my regional settings at configured to display "$ 1234.25", but I'm getting "123.25$", why is the money symbol at the right side, instead of using the regional setting?. Did you use the CLocale unit ? Michael. _______________________________________________ fpc-pascal maillist  -  http://lists.freepascal.org/mailman/listinfo/fpc-pascal

No, but after you mentioned I included it in my "uses". The result was a number without the money symbol.  
Leonardo M. Ramé
http://leonardorame.blogspot.com

Leonardo M. Ramé
to Leonardo M. Ramé

----- Original Message -----

Show quoted text 41 lines
From: Leonardo M. Ramé To: FPC-Pascal users discussions Cc: Sent: Saturday, June 9, 2012 12:31 PM Subject: Re: [fpc-pascal] Currency symbol wrong location ----- Original Message ----- > From: Michael Van Canneyt > To: Leonardo M. Ramé ; FPC-Pascal users discussions > Cc: > Sent: Saturday, June 9, 2012 11:59 AM > Subject: Re: [fpc-pascal] Currency symbol wrong location > > > > On Sat, 9 Jun 2012, Leonardo M. Ramé wrote: > >>   Hi, I want to format a float number to currency. To do this, I use the > Format function using the %m format, as this: >> >>   Format('%m', [123.25]); >> >>   I'm using Ubuntu 12.04 and my regional settings at configured to > display "$ 1234.25", but I'm getting "123.25$", why is > the money symbol at the right side, instead of using the regional setting?. > > Did you use the CLocale unit ? > > Michael. > _______________________________________________ > fpc-pascal maillist  -  > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > No, but after you mentioned I included it in my "uses". The result was a number without the money symbol.  

Apart from that, I'm looking a cross-platform solution.  
Leonardo M. Ramé
http://leonardorame.blogspot.com

Michael Van Canneyt
to Leonardo M. Ramé: ----- Original Message ----- No, but after you mentioned I included it in my "uses". The…
Leonardo M. Ramé wrote 30 lines
----- Original Message ----- > From: Michael Van Canneyt > To: Leonardo M. Ramé ; FPC-Pascal users discussions > Cc: > Sent: Saturday, June 9, 2012 11:59 AM > Subject: Re: [fpc-pascal] Currency symbol wrong location > > > > On Sat, 9 Jun 2012, Leonardo M. Ramé wrote: > >> Hi, I want to format a float number to currency. To do this, I use the > Format function using the %m format, as this: >> >> Format('%m', [123.25]); >> >> I'm using Ubuntu 12.04 and my regional settings at configured to > display "$ 1234.25", but I'm getting "123.25$", why is > the money symbol at the right side, instead of using the regional setting?. > > Did you use the CLocale unit ? > > Michael. > _______________________________________________ > fpc-pascal maillist  -  > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > No, but after you mentioned I included it in my "uses". The result was a number without the money symbol.

That probably means the clocale does not know how to handle the currency symbol ?

Michael.

Marco van de Voort
to Leonardo M. Ramé: Hi, I want to format a float number to currency. To do this, I use the Format function…

In our previous episode, Leonardo M. Ram? said:

Show quoted text 5 lines
Hi, I want to format a float number to currency. To do this, I use the Format function using the %m format, as this: Format('%m', [123.25]); I'm using Ubuntu 12.04 and my regional settings at configured to display "$ 1234.25", but I'm getting "123.25$", why is the money symbol at the right side, instead of using the regional setting?.

This is as per doc?

http://www.freepascal.org/docs-html/rtl/sysutils/format.html

FloatToStrF(Argument,ffGeneral,Precision,3)

M Currency format. the next argument in the var{Args} array must be a floating point value. The argument is converted to a decimal string using currency notation. This means that fixed-point notation is used, but that the currency symbol is appended. If precision is specified, then then it overrides the CurrencyDecimals global variable used in the FloatToStrF

In short, the M specifier formats it's argument as follows:

FloatToStrF(Argument,ffCurrency,9999,Precision)

Note the /append/ :-)

Ludo Brands
to Marco van de Voort
Show quoted text 20 lines
This is as per doc? http://www.freepascal.org/docs-html/rtl/sysutils/format.html FloatToStrF(Argument,ffGeneral,Precision,3) M Currency format. the next argument in the var{Args} array must be a floating point value. The argument is converted to a decimal string using currency notation. This means that fixed-point notation is used, but that the currency symbol is appended. If precision is specified, then then it overrides the CurrencyDecimals global variable used in the FloatToStrF In short, the M specifier formats it's argument as follows: FloatToStrF(Argument,ffCurrency,9999,Precision) Note the /append/ :-)

Then there seems to be a contradiction in the doc. The position of the currency symbol in FloatToStrF with ffCurrency is determined by CurrencyFormat.

  CurrencyFormat:=0;
  s:=FloatToStrF(123.25,ffCurrency,5,2);
  s:=Format('%m', [123.25]);

Both calls return $123.25 in s.

Ludo

Leonardo M. Ramé
to Ludo Brands

----- Original Message -----

Show quoted text 39 lines
From: Ludo Brands To: 'FPC-Pascal users discussions' Cc: Sent: Saturday, June 9, 2012 12:54 PM Subject: RE : [fpc-pascal] Currency symbol wrong location > This is as per doc? > > http://www.freepascal.org/docs-html/rtl/sysutils/format.html > > FloatToStrF(Argument,ffGeneral,Precision,3) > > M    Currency format. the next argument in the var{Args} > array must be a > floating point value. The argument is converted to a decimal > string using currency notation. This means that fixed-point > notation is used, but that the currency symbol is appended. > If precision is specified, then then it overrides the > CurrencyDecimals global variable used in the FloatToStrF > >     In short, the M specifier formats it's argument as follows: > >     FloatToStrF(Argument,ffCurrency,9999,Precision) > > Note the /append/  :-) > Then there seems to be a contradiction in the doc. The position of the currency symbol in FloatToStrF with ffCurrency is determined by CurrencyFormat.   CurrencyFormat:=0;   s:=FloatToStrF(123.25,ffCurrency,5,2);   s:=Format('%m', [123.25]); Both calls return $123.25 in s. Ludo  

Thanks, that worked. The trick was CurrencyFormat := 0;  
Leonardo M. Ramé
http://leonardorame.blogspot.com