String Utilities
Unit: StrUtil
String conversion and manipulation functions.
Functions
function StrToInt(const S: string): LongInt;
function StrToReal(const S: string): Real;
function IntToStr(Value: LongInt): string;
function Trim(const S: string): string;
function HexStr(Value: Word; Digits: Byte): string;
function HexStrToWord(const S: string): Word;
Examples
uses StrUtil;
var
I: LongInt;
R: Real;
S: string;
begin
I := StrToInt('1234'); { 1234 }
R := StrToReal('3.14'); { 3.14 }
S := IntToStr(42); { '42' }
S := Trim(' hello '); { 'hello' }
S := HexStr($A5, 2); { 'A5' }
I := HexStrToWord('FF00'); { 65280 }
end;
Notes
StrToInt/StrToRealreturn 0 on invalid inputHexStrpads with zeros to specified digit countHexStrToWordsupports uppercase/lowercase hex digits