BaseToStr

BaseToStr — General function for converting binary, hex, octal or a custom base Key to a string.

BaseToStr(Value : longint; const Key : String; Digits : Byte) : String;

Example 1: Hex (Base 16)

BaseToStr(255,'0123456789ABCDEF')

Returns:

FF

Note if i=255 and i is an Integer, overloaded BaseStr(i,'0123456789ABCDEF') will return '000000FF' (knows it is an 32 bit Integer)

Example 2: Binary (Base 2)

BaseToStr(5,'01',8)

Returns:

00000101

Example 3: A..Z (Base 26)

BaseToStr(675,'ABCDEFGHIJKLMNOPQRSTUVWXYZ',4)

Returns:

AAZZ

Example 4: 0..9, A..V (Base 32)

BaseToStr(1023,'0123456789ABCDEFGHIJKLMNOPQRSTUV',4)

Returns:

00VV
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License