ArrayOfChar

Operations on ARRAY OF CHAR. All operations sets the NUL termination if possible

Procedures

Clear

PROCEDURE Clear* (VAR str : ARRAY OF CHAR);

NulTerminate

Ensure string is NUL terminated

PROCEDURE NulTerminate* (VAR str : ARRAY OF CHAR);

Capacity

Return capacity of the array

PROCEDURE Capacity* (str- : ARRAY OF CHAR): LENGTH;

Length

Find length of C style NUL terminated string or length of array if not NUL terminated

PROCEDURE Length* (str-: ARRAY OF CHAR) : LENGTH;

Assign

Assign src to dst

PROCEDURE Assign* (VAR dst : ARRAY OF CHAR; src- : ARRAY OF CHAR);

FillChar

Fill string dst with char chr

PROCEDURE FillChar* (VAR dst : ARRAY OF CHAR; ch : CHAR);

AppendChar

Append ch to dst

PROCEDURE AppendChar* (VAR dst : ARRAY OF CHAR; ch : CHAR);

Append

Append src to dst

PROCEDURE Append* (VAR dst : ARRAY OF CHAR; src- : ARRAY OF CHAR);

Extract

Extract substring to dst from src from start position and count length.

PROCEDURE Extract* (VAR dst : ARRAY OF CHAR; src- : ARRAY OF CHAR; start, count: LENGTH);

Compare

Compare strings left and right.

  • 0 if left = right

  • -1 if left < right

  • +1 if left > right

PROCEDURE Compare* (left-, right- : ARRAY OF CHAR): INTEGER;

Equal

Test if left and right is equal.

PROCEDURE Equal* (left-, right- : ARRAY OF CHAR): BOOLEAN;

IndexChar

Index of char in str. zero based index with -1 indicating char not found

PROCEDURE IndexChar* (ch : CHAR; str- : ARRAY OF CHAR; start: LENGTH): LENGTH;

Index

Index of pattern in str. -1 indicating pattern not found.

This is the TwoWay algorithm to avoid quadratic behaviour
PROCEDURE Index* (pattern-, str-: ARRAY OF CHAR; start : LENGTH): LENGTH;

Delete

Delete count characters from dst starting from start.

PROCEDURE Delete* (VAR dst: ARRAY OF CHAR; start, count: LENGTH);

Insert

Insert src into dst at start.

PROCEDURE Insert* (VAR dst : ARRAY OF CHAR; src- : ARRAY OF CHAR; start: LENGTH);

Replace

Replace old string with new string starting at index start.

PROCEDURE Replace* (VAR dst: ARRAY OF CHAR; old-, new-: ARRAY OF CHAR; start : LENGTH);

LeftTrim

Remove white space & control characters from left side of string.

PROCEDURE LeftTrim* (VAR dst: ARRAY OF CHAR);

RightTrim

Remove white space & special characters from right side of string.

PROCEDURE RightTrim* (VAR dst: ARRAY OF CHAR);

LeftPad

Left justified of length width with ch.

PROCEDURE LeftPad* (VAR dst: ARRAY OF CHAR; width : LENGTH; ch : CHAR);

RightPad

Right justified of length width with ch.

PROCEDURE RightPad* (VAR dst: ARRAY OF CHAR; width : LENGTH; ch : CHAR);

Trim

Remove white space & special characters from right & left side of string.

PROCEDURE Trim* (VAR dst: ARRAY OF CHAR);

LowerCase

Transform string inplace to lower case (Only takes into account the ASCII characters).

PROCEDURE LowerCase* (VAR dst: ARRAY OF CHAR);

UpperCase

Transform string inplace to upper case (Only takes into account the ASCII characters).

PROCEDURE UpperCase* (VAR dst: ARRAY OF CHAR);

Capitalize

Capitalize string inplace. (Only takes into account the ASCII characters).

PROCEDURE Capitalize* (VAR dst: ARRAY OF CHAR);

StartsWith

Check if string str starts with prefix.

PROCEDURE StartsWith* (str-, prefix- : ARRAY OF CHAR): BOOLEAN;

EndsWith

Check if string str ends with postfix.

PROCEDURE EndsWith* (str-, postfix- : ARRAY OF CHAR): BOOLEAN;

Match

Return TRUE if patter matches str.

  • ? mathches a single character

  • * mathches any sequence of characters including zero length

PROCEDURE Match* (str- : ARRAY OF CHAR; pattern- : ARRAY OF CHAR; IgnoreCase : BOOLEAN): BOOLEAN;

Format

Format ARRAY OF CHAR.

  • width : Total field with. Can overflow if string is bigger.

  • prec : The number of characters in string to add (if prec > 0)

The alignment formatting flags are Left, Right & Center . The Upper flag will make the whole string upper case. The Alt flag will capitalize the string.

PROCEDURE Format*(VAR Writer : Type.Stream; str- : ARRAY OF CHAR; width, prec: INTEGER; flags: SET);

Hash

Hash value of string (64/32bit FNV-1a)

PROCEDURE Hash* (src- : ARRAY OF CHAR): LENGTH;