# Unit synautil

Description | uses | Classes, Interfaces, Objects and Records | Functions and Procedures | Types | Constants | Variables

## Description

## uses

- Windows
- SysUtils
- Classes
- SynaFpc

## Overview

### Functions and Procedures

`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: String): 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: LongWord;`
`function TickDelta(TickOld, TickNew: LongWord): LongWord;`
`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 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: AnsiString): AnsiString;`
`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: AnsiString): 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(const Value: string; Quote: Char): string;`
`function QuoteStr(const 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);`
`function GetTempFile(const Dir, prefix: AnsiString): AnsiString;`
`function PadString(const Value: AnsiString; len: integer; Pad: AnsiChar): AnsiString;`
`function XorString(Indata1, Indata2: AnsiString): AnsiString;`
`function NormalizeHeader(Value: TStrings; var Index: Integer): string;`
`procedure SearchForLineBreak(var APtr:PANSIChar; AEtx:PANSIChar; out ABol:PANSIChar; out ALength:integer);`
`procedure SkipLineBreak(var APtr:PANSIChar; AEtx:PANSIChar);`
`procedure SkipNullLines (var APtr:PANSIChar; AEtx:PANSIChar);`
`procedure CopyLinesFromStreamUntilNullLine(var APtr:PANSIChar; AEtx:PANSIChar; ALines:TStrings);`
`procedure CopyLinesFromStreamUntilBoundary(var APtr:PANSIChar; AEtx:PANSIChar; ALines:TStrings; const ABoundary:ANSIString);`
`function SearchForBoundary (var APtr:PANSIChar; AEtx:PANSIChar; const ABoundary:ANSIString): PANSIChar;`
`function MatchBoundary (ABOL,AETX:PANSIChar; const ABoundary:ANSIString): PANSIChar;`
`function MatchLastBoundary (ABOL,AETX:PANSIChar; const ABoundary:ANSIString): PANSIChar;`
`function BuildStringFromBuffer (AStx,AEtx:PANSIChar): ANSIString;`

### Variables

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

## Description

### Functions and Procedures

`function TimeZoneBias: integer;`

Return your timezone bias from UTC time in minutes.

`function TimeZone: string;`

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

`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 CDateTime(t: TDateTime): string;`

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

`function SimpleDateTime(t: TDateTime): string;`

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

`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 GetMonthNumber(Value: String): 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 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 GetDateMDYFromStr(Value: string): TDateTime;`

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

`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.

`function GetUTTime: TDateTime;`

Return current system date and time in UTC timezone.

`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 GetTick: LongWord;`

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

`function TickDelta(TickOld, TickNew: LongWord): LongWord;`

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

`function CodeInt(Value: Word): Ansistring;`

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

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

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

`function CodeLongInt(Value: LongInt): Ansistring;`

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

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

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

`function DumpStr(const Buffer: Ansistring): string;`

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

`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.

`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 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 TrimSP(const S: string): string;`

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

`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 GetParameter(const Value, Parameter: string): string;`

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

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

parse value string with elements differed by Delimiter into stringlist.

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

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

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

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

`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 StrToHex(const Value: Ansistring): string;`

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

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

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

`function BinToInt(const Value: string): Integer;`

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

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

Parses a URL to its various components.

`function ReplaceString(Value, Search, Replace: AnsiString): AnsiString;`

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

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

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

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

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

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

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

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

Fetch string from left of Value string.

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

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

`function IsBinaryString(const Value: AnsiString): Boolean;`

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

`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

`Procedure StringsTrim(const value: TStrings);`

Delete empty strings from end of stringlist.

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

Like Pos function, buf from given string possition.

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

Increase pointer by value.

`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 CountOfChar(const Value: string; Chr: char): integer;`

Return count of Chr in Value string.

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

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

`function QuoteStr(const Value: string; Quote: Char): string;`

Quote Value string. If Value contains some Quote chars, then it is doubled.

`procedure HeadersToList(const Value: TStrings);`

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

`procedure ListToHeaders(const Value: TStrings);`

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

`function SwapBytes(Value: integer): integer;`

swap bytes in integer.

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

read string with requested length form stream.

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

write string to stream.

`function GetTempFile(const Dir, prefix: AnsiString): AnsiString;`

Return filename of new temporary file in Dir (if empty, then default temporary directory is used) and with optional filename prefix.

`function PadString(const Value: AnsiString; len: integer; Pad: AnsiChar): AnsiString;`

Return padded string. If length is greater, string is truncated. If length is smaller, string is padded by Pad character.

`function XorString(Indata1, Indata2: AnsiString): AnsiString;`

XOR each byte in the strings

`function NormalizeHeader(Value: TStrings; var Index: Integer): string;`

Read header from "Value" stringlist beginning at "Index" position. If header is Splitted into multiple lines, then this procedure de-split it into one line.

`procedure SearchForLineBreak(var APtr:PANSIChar; AEtx:PANSIChar; out ABol:PANSIChar; out ALength:integer);`

Search for one of line terminators CR, LF or NUL. Return position of the line beginning and length of text.

`procedure SkipLineBreak(var APtr:PANSIChar; AEtx:PANSIChar);`

Skip both line terminators CR LF (if any). Move APtr position forward.

`procedure SkipNullLines (var APtr:PANSIChar; AEtx:PANSIChar);`

Skip all blank lines in a buffer starting at APtr and move APtr position forward.

`procedure CopyLinesFromStreamUntilNullLine(var APtr:PANSIChar; AEtx:PANSIChar; ALines:TStrings);`

Copy all lines from a buffer starting at APtr to ALines until empty line or end of the buffer is reached. Move APtr position forward).

`procedure CopyLinesFromStreamUntilBoundary(var APtr:PANSIChar; AEtx:PANSIChar; ALines:TStrings; const ABoundary:ANSIString);`

Copy all lines from a buffer starting at APtr to ALines until ABoundary or end of the buffer is reached. Move APtr position forward).

`function SearchForBoundary (var APtr:PANSIChar; AEtx:PANSIChar; const ABoundary:ANSIString): PANSIChar;`

Search ABoundary in a buffer starting at APtr. Return beginning of the ABoundary. Move APtr forward behind a trailing CRLF if any).

`function MatchBoundary (ABOL,AETX:PANSIChar; const ABoundary:ANSIString): PANSIChar;`

Compare a text at position ABOL with ABoundary and return position behind the match (including a trailing CRLF if any).

`function MatchLastBoundary (ABOL,AETX:PANSIChar; const ABoundary:ANSIString): PANSIChar;`

Compare a text at position ABOL with ABoundary + the last boundary suffix and return position behind the match (including a trailing CRLF if any).

`function BuildStringFromBuffer (AStx,AEtx:PANSIChar): ANSIString;`

Copy data from a buffer starting at position APtr and delimited by AEtx position into ANSIString.

### Variables

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

can be used for your own months strings for GetMonthNumber

Generated by PasDoc 0.9.0 on 2012-04-23 21:38:52