1

It was quite easy to get the char from using an old way like this:

var
FS:TFormatSettings;
  begin
    FS:=TFormatSettings.Create;
...

Record member FS.DecimalSeparator will contain the reuired Char. This method have been working fine in Win FMX applications compiled by my XE5 IDE. But looking for the proper ways of fething the character in FireMonkey I read some opinions that this way is pernicious and deprecated. I also read that this is not supported by later versions of Delphi (I can not check it myself). But what then will be the proper and reliable way? Especially if the code is expected to be capable of migrating to Android?

Community
  • 1
  • 1
asd-tm
  • 3,381
  • 2
  • 24
  • 41
  • Looking at TFormatSettings code I can only see platform defines for Windows, MacOS and Linux (yea I was surprised about this as your probably are) but nothing about Android. So I don't know if this is even fully supported on Android OS. – SilverWarior Sep 11 '15 at 21:00
  • Does Android as OS even expose such information to its applications? – SilverWarior Sep 11 '15 at 21:01
  • @SilverWarior Thank you for your attention to my post. Yes. I was also digging in the code of TFormatSettings. I have the following background for the question. I am coding a `TGrid` descendant class that as I hope will be suitable for future code migration of my main project to Android. Some of the columns (cells) require input control. Android will display a screen keyboard with the decimal separator button set by locale but the user can try to input this character >1 times. Moreover. The float (currency) to string cast also requires this data. – asd-tm Sep 11 '15 at 21:19
  • @SilverWarior: if you look again more carefully, the RTL actually has a 4th implementation for initializing `TFormatSettings` - the LIBICU library. At the very top of the `SysUtils` unit, `USE_LIBICU` is defined for Android: `{$IFDEF ANDROID}{$DEFINE USE_LIBICU}{$ENDIF}` – Remy Lebeau Sep 12 '15 at 03:20
  • Thank you @RemyLebeau. You ever help people with excellent pieces of advice! I've missed the directive. – asd-tm Sep 12 '15 at 08:59
  • @SilverWarior Thank you for participation. It seems we have missed the Android directive in `System.SysUtils`. We can continue using `TFormatSettings` for the purpose. – asd-tm Sep 12 '15 at 09:02

1 Answers1

3

The DecimalSeparator global variable is what was deprecated, along with all the other locale related global variables. They have now been removed.

The new and supported way to access this information is through TFormatSettings. So contrary to your question, that type is not deprecated. Quite the opposite, it is the recommended way to obtain locale information.

var
  fs: TFormatSettings;
....
fs := TFormatSettings.Create;
// use fs.DecimalSeparator;
David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490