Overloaded NamedFormat with FormatSettings parameter
This commit is contained in:
parent
06e559505d
commit
2b51a19169
@ -10,7 +10,8 @@ unit X2UtNamedFormat;
|
|||||||
|
|
||||||
interface
|
interface
|
||||||
uses
|
uses
|
||||||
Classes;
|
Classes,
|
||||||
|
SysUtils;
|
||||||
|
|
||||||
|
|
||||||
type
|
type
|
||||||
@ -37,12 +38,16 @@ type
|
|||||||
be affected by named specifiers! It is strongly recommended to name all
|
be affected by named specifiers! It is strongly recommended to name all
|
||||||
specifiers.
|
specifiers.
|
||||||
}
|
}
|
||||||
function NamedFormat(const AFormat: String; AParams: array of const): String;
|
function NamedFormat(const AFormat: String; AParams: array of const; AFormatSettings: TFormatSettings): String; overload;
|
||||||
|
function NamedFormat(const AFormat: String; AParams: array of const): String; overload;
|
||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
uses
|
uses
|
||||||
SysUtils;
|
Windows;
|
||||||
|
|
||||||
|
|
||||||
|
{$I X2UtCompilerVersion.inc}
|
||||||
|
|
||||||
|
|
||||||
type
|
type
|
||||||
@ -92,7 +97,21 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function NamedFormat(const AFormat: String; AParams: array of const): String;
|
function NamedFormat(const AFormat: String; AParams: array of const): String; overload;
|
||||||
|
var
|
||||||
|
formatSettings: TFormatSettings;
|
||||||
|
|
||||||
|
begin
|
||||||
|
{$IFDEF DXE2PLUS}
|
||||||
|
formatSettings := TFormatSettings.Create;
|
||||||
|
{$ELSE}
|
||||||
|
GetLocaleFormatSettings(LOCALE_SYSTEM_DEFAULT, formatSettings);
|
||||||
|
{$ENDIF}
|
||||||
|
Result := NamedFormat(AFormat, AParams, formatSettings);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function NamedFormat(const AFormat: String; AParams: array of const; AFormatSettings: TFormatSettings): String;
|
||||||
var
|
var
|
||||||
currentPos: PChar;
|
currentPos: PChar;
|
||||||
formatEnd: PChar;
|
formatEnd: PChar;
|
||||||
@ -195,7 +214,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
try
|
try
|
||||||
Result := Format(formatString, paramValues);
|
|
||||||
|
Result := Format(formatString, paramValues, AFormatSettings);
|
||||||
except
|
except
|
||||||
on E:EConvertError do
|
on E:EConvertError do
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user