UCLeft (open)

Returns the left part of a UTF-8 string.

Syntax

// Core function, no LOADLIB necessary

STRING FUNCTION UCLeft(STRING text, INTEGER numchars)

Parameters

STRING text

String to return a part from

INTEGER numchars

Number of characters (not bytes!) to return

Return value

STRING

The requested part of the string

Description

Left returns the first @italic numchars characters from a string. If a string contains less than the requested number of characters, the entire string is returned.

Examples

// returns 'ab'
STRING example1 := UCLeft("abcdef", 2);

// returns '€uro'
STRING example2 := UCLeft("€uro", 4);

// returns '€u'
STRING example3 := Left("€uro", 4)

// returns the entire string, e.g 'abcdef'
STRING example4 := UCLeft("abcdef", 100);

// returns an empty string
STRING example5 := UCLeft("abcdef", -10);