Unit synautil

DescriptionusesClasses, Interfaces and ObjectsFunctions and ProceduresTypesConstantsVariables

Description

Support procedures and functions

Functions and Procedures

Overview

function TimeZoneBias: integer;
function TimeZone: string;
function Rfc822DateTime(t: TDateTime): string;
function CDateTime(t: TDateTime): string;
function SimpleDateTime(t: TDateTime): string;
function AnsiCDateTime(t: TDateTime): string;
function GetMonthNumber(Value: AnsiString): integer;
function GetTimeFromStr(Value: string): TDateTime;
function GetDateMDYFromStr(Value: string): TDateTime;
function DecodeRfcDateTime(Value: string): TDateTime;
function GetUTTime: TDateTime;
function SetUTTime(Newdt: TDateTime): Boolean;
function GetTick: ULong;
function TickDelta(TickOld, TickNew: ULong): ULong;
function CodeInt(Value: Word): Ansistring;
function DecodeInt(const Value: Ansistring; Index: Integer): Word;
function CodeLongInt(Value: LongInt): Ansistring;
function DecodeLongInt(const Value: Ansistring; Index: Integer): LongInt;
function IsIP(const Value: string): Boolean;
function IsIP6(const Value: string): Boolean;
function IPToID(Host: string): string;
function DumpStr(const Buffer: Ansistring): string;
function DumpExStr(const Buffer: Ansistring): string;
procedure Dump(const Buffer: AnsiString; DumpFile: string);
procedure DumpEx(const Buffer: AnsiString; DumpFile: string);
function TrimSPLeft(const S: string): string;
function TrimSPRight(const S: string): string;
function TrimSP(const S: string): string;
function SeparateLeft(const Value, Delimiter: string): string;
function SeparateRight(const Value, Delimiter: string): string;
function GetParameter(const Value, Parameter: string): string;
procedure ParseParametersEx(Value, Delimiter: string; const Parameters: TStrings);
procedure ParseParameters(Value: string; const Parameters: TStrings);
function IndexByBegin(Value: string; const List: TStrings): integer;
function GetEmailAddr(const Value: string): string;
function GetEmailDesc(Value: string): string;
function StrToHex(const Value: Ansistring): string;
function IntToBin(Value: Integer; Digits: Byte): string;
function BinToInt(const Value: string): Integer;
function ParseURL(URL: string; var Prot, User, Pass, Host, Port, Path, Para: string): string;
function ReplaceString(Value, Search, Replace: string): string;
function RPosEx(const Sub, Value: string; From: integer): Integer;
function RPos(const Sub, Value: String): Integer;
function FetchBin(var Value: string; const Delimiter: string): string;
function Fetch(var Value: string; const Delimiter: string): string;
function FetchEx(var Value: string; const Delimiter, Quotation: string): string;
function IsBinaryString(const Value: string): Boolean;
function PosCRLF(const Value: AnsiString; var Terminator: AnsiString): integer;
Procedure StringsTrim(const value: TStrings);
function PosFrom(const SubStr, Value: String; From: integer): integer;
function IncPoint(const p: pointer; Value: integer): pointer;
function GetBetween(const PairBegin, PairEnd, Value: string): string;
function CountOfChar(const Value: string; Chr: char): integer;
function UnquoteStr(Value: string; Quote: Char): string;
procedure HeadersToList(const Value: TStrings);
procedure ListToHeaders(const Value: TStrings);
function SwapBytes(Value: integer): integer;
function ReadStrFromStream(const Stream: TStream; len: integer): AnsiString;
procedure WriteStrToStream(const Stream: TStream; Value: AnsiString);

Description

function AnsiCDateTime(t: TDateTime): string;

Returns date and time in format defined in ANSI C compilers in format "ddd mmm d hh:nn:ss yyyy"

function BinToInt(const Value: string): Integer;

Returns an integer equivalent of the binary string in "Value". (i.e. ('10001010') returns 138)

function CDateTime(t: TDateTime): string;

Returns date and time in format defined in C compilers in format "mmm dd hh:nn:ss"

function CodeInt(Value: Word): Ansistring;

Return two characters, which ordinal values represents the value in byte format. (High-endian)

function CodeLongInt(Value: LongInt): Ansistring;

Return four characters, which ordinal values represents the value in byte format. (High-endian)

function CountOfChar(const Value: string; Chr: char): integer;

Return count of Chr in Value string.

function DecodeInt(const Value: Ansistring; Index: Integer): Word;

Decodes two characters located at "Index" offset position of the "Value" string to Word values.

function DecodeLongInt(const Value: Ansistring; Index: Integer): LongInt;

Decodes four characters located at "Index" offset position of the "Value" string to LongInt values.

function DecodeRfcDateTime(Value: string): TDateTime;

Decode various string representations of date and time to Tdatetime type. This function do all timezone corrections too! This function can decode lot of formats like:


 ddd, d mmm yyyy hh:mm:ss
 ddd, d mmm yy hh:mm:ss
 ddd, mmm d yyyy hh:mm:ss
 ddd mmm dd hh:mm:ss yyyy

and more with lot of modifications, include:


Sun, 06 Nov 1994 08:49:37 GMT    ; RFC 822, updated by RFC 1123
Sunday, 06-Nov-94 08:49:37 GMT   ; RFC 850, obsoleted by RFC 1036
Sun Nov  6 08:49:37 1994         ; ANSI C
Timezone corrections known lot of symbolic timezone names (like CEST, EDT, etc.) or numeric representation (like +0200). By convention defined in RFC timezone +0000 is GMT and -0000 is current your system timezone.

procedure Dump(const Buffer: AnsiString; DumpFile: string);

Dump binary buffer stored in a string to a file with DumpFile filename.

procedure DumpEx(const Buffer: AnsiString; DumpFile: string);

Dump binary buffer stored in a string to a file with DumpFile filename. All bytes with code of character is written as character, not as hexadecimal value.

function DumpExStr(const Buffer: Ansistring): string;

Dump binary buffer stored in a string to a result string. All bytes with code of character is written as character, not as hexadecimal value.

function DumpStr(const Buffer: Ansistring): string;

Dump binary buffer stored in a string to a result string.

function Fetch(var Value: string; const Delimiter: string): string;

Fetch string from left of Value string.

function FetchBin(var Value: string; const Delimiter: string): string;

Like Fetch, but working with binary strings, not with text.

function FetchEx(var Value: string; const Delimiter, Quotation: string): string;

Fetch string from left of Value string. This function ignore delimitesr inside quotations.

function GetBetween(const PairBegin, PairEnd, Value: string): string;

Get string between PairBegin and PairEnd. This function respect nesting. For example:


 Value is: 'Hi! (hello(yes!))' 
 pairbegin is: '(' 
 pairend is: ')' 
 In this case result is: 'hello(yes!)' 

function GetDateMDYFromStr(Value: string): TDateTime;

Decode string in format "m-d-y" to TDateTime type.

function GetEmailAddr(const Value: string): string;

Returns only the e-mail portion of an address from the full address format. i.e. returns 'nobody@somewhere.com' from '"someone" <nobody@somewhere.com>'

function GetEmailDesc(Value: string): string;

Returns only the description part from a full address format. i.e. returns 'someone' from '"someone" <nobody@somewhere.com>'

function GetMonthNumber(Value: AnsiString): integer;

Decode three-letter string with name of month to their month number. If string not match any month name, then is returned 0. For parsing are used predefined names for English, French and German and names from system locale too.

function GetParameter(const Value, Parameter: string): string;

Returns parameter value from string in format: parameter1="value1"; parameter2=value2

function GetTick: ULong;

Return current value of system timer with precizion 1 millisecond. Good for measure time difference.

function GetTimeFromStr(Value: string): TDateTime;

Return decoded time from given string. Time must be witch separator ':'. You can use "hh:mm" or "hh:mm:ss".

function GetUTTime: TDateTime;

Return current system date and time in UTC timezone.

procedure HeadersToList(const Value: TStrings);

Convert lines in stringlist from 'name: value' form to 'name=value' form.

function IncPoint(const p: pointer; Value: integer): pointer;

Increase pointer by value.

function IndexByBegin(Value: string; const List: TStrings): integer;

Index of string in stringlist with same beginning as Value is returned.

function IntToBin(Value: Integer; Digits: Byte): string;

Returns a string of binary "Digits" representing "Value".

function IPToID(Host: string): string;

Returns a string with the "Host" ip address converted to binary form.

function IsBinaryString(const Value: string): Boolean;

If string is binary string (contains non-printable characters), then is returned true.

function IsIP(const Value: string): Boolean;

Returns True, if "Value" is a valid IPv4 address. Cannot be a symbolic Name!

function IsIP6(const Value: string): Boolean;

Returns True, if "Value" is a valid IPv6 address. Cannot be a symbolic Name!

procedure ListToHeaders(const Value: TStrings);

Convert lines in stringlist from 'name=value' form to 'name: value' form.

procedure ParseParameters(Value: string; const Parameters: TStrings);

parse value string with elements differed by ';' into stringlist.

procedure ParseParametersEx(Value, Delimiter: string; const Parameters: TStrings);

parse value string with elements differed by Delimiter into stringlist.

function ParseURL(URL: string; var Prot, User, Pass, Host, Port, Path, Para: string): string;

Parses a URL to its various components.

function PosCRLF(const Value: AnsiString; var Terminator: AnsiString): integer;

return position of string terminator in string. If terminator found, then is returned in terminator parameter. Possible line terminators are: CRLF, LFCR, CR, LF

function PosFrom(const SubStr, Value: String; From: integer): integer;

Like Pos function, buf from given string possition.

function ReadStrFromStream(const Stream: TStream; len: integer): AnsiString;

read string with requested length form stream.

function ReplaceString(Value, Search, Replace: string): string;

Replaces all "Search" string values found within "Value" string, with the "Replace" string value.

function Rfc822DateTime(t: TDateTime): string;

Returns current time in format defined in RFC-822. Useful for SMTP messages, but other protocols use this time format as well. Results contains the timezone specification. Four digit year is used to break any Y2K concerns. (Example 'Fri, 15 Oct 1999 21:14:56 +0200')

function RPos(const Sub, Value: String): Integer;

It is like POS function, but from right side of Value string.

function RPosEx(const Sub, Value: string; From: integer): Integer;

It is like RPos, but search is from specified possition.

function SeparateLeft(const Value, Delimiter: string): string;

Returns a portion of the "Value" string located to the left of the "Delimiter" string. If a delimiter is not found, results is original string.

function SeparateRight(const Value, Delimiter: string): string;

Returns the portion of the "Value" string located to the right of the "Delimiter" string. If a delimiter is not found, results is original string.

function SetUTTime(Newdt: TDateTime): Boolean;

Set Newdt as current system date and time in UTC timezone. This function work only if you have administrator rights!

function SimpleDateTime(t: TDateTime): string;

Returns date and time in format defined in format 'yymmdd hhnnss'

Procedure StringsTrim(const value: TStrings);

Delete empty strings from end of stringlist.

function StrToHex(const Value: Ansistring): string;

Returns a string with hexadecimal digits representing the corresponding values of the bytes found in "Value" string.

function SwapBytes(Value: integer): integer;

swap bytes in integer.

function TickDelta(TickOld, TickNew: ULong): ULong;

Return difference between two timestamps. It working fine only for differences smaller then maxint. (difference must be smaller then 24 days.)

function TimeZone: string;

Return your timezone bias from UTC time in string representation like "+0200".

function TimeZoneBias: integer;

Return your timezone bias from UTC time in minutes.

function TrimSP(const S: string): string;

Like Trim, but remove only spaces, not control characters!

function TrimSPLeft(const S: string): string;

Like TrimLeft, but remove only spaces, not control characters!

function TrimSPRight(const S: string): string;

Like TrimRight, but remove only spaces, not control characters!

function UnquoteStr(Value: string; Quote: Char): string;

Remove quotation from Value string. If Value is not quoted, then return same string without any modification.

procedure WriteStrToStream(const Stream: TStream; Value: AnsiString);

write string to stream.

Variables

NameDescription
CustomMonthNames: array[1..12] of string;

can be used for your own months strings for GetMonthNumber


Generated by PasDoc 0.8.8.2 on 2005-01-19 20:01:20