Skip to main content

Trim

function Trim(S: String): String;

Example

procedure ScriptEvent(var Value: variant);
begin
Value := Trim(' Velox EDI '); // Velox EDI
end;

Usage

Trim returns a copy without leading or trailing Velox control and space characters.

Parameters and result

ItemTypeDescription
SStringText to trim. ANSI, WideString and UnicodeString values are accepted.
ResultStringTrimmed copy. Empty or entirely trimmable input returns empty.

For the current Velox RTL, trimming removes character values at or below ordinary space (#32) from both ends. This covers ASCII space and control characters such as tab, carriage return and line feed. It is not general Unicode whitespace normalisation: for example, non-breaking and other Unicode spaces are not removed merely because Unicode classifies them as whitespace.

Additional Technical Info

Trim returns a copy with leading and trailing Delphi trim characters removed. Interior characters are preserved.

The example is fictional and source-reviewed only.

Actual-type dispatch

This is modified PascalScript standard-function selector 12:

  • a UnicodeString actual value calls Delphi's Unicode Trim overload;
  • a WideString actual value calls the WideString overload; and
  • the ANSI string branch converts through the native Delphi string type for trimming and converts the result back.

The input value is not modified. Only the returned copy changes, and sequences inside the retained boundaries remain byte-for-byte/code-unit-for-code-unit intact.

Performance and concurrency

The implementation scans the boundaries and returns a copied result. The ANSI branch performs additional string conversions. No shared state is mutated.

External references

Created 2026-07-15