Wiz*_*ard 9 delphi string floating-point
我有一个西班牙语用户正在invalid floating point error
这样做
var
S : String;
R : Real;
begin
S := '3.12345';
R := StrToFloat(S); //- Exception here.
Run Code Online (Sandbox Code Playgroud)
原因是他的位置,
用于小数位!
我怎样才能安全地将上面的字符串转换为用户的浮点数,而不会将其轰炸出来.
Joh*_*ica 12
滚动您自己的StrToFloat版本
function StrToFloat_UK(const AStr: string): Float;
var
FS: TFormatSettings;
begin
FS.Create('en-UK');
Result:= StrToFloat(AStr, FS):
end;
Run Code Online (Sandbox Code Playgroud)
并使用它代替StrToFloat.