Core Function TrimToNull

From Sputnik Wiki
Jump to: navigation, search
TrimToNull( <string> )

Contents

Description

Strip all zero chars (nulls) from the end of a string.

Parameters

string

The string to trim.

Return Value

Success: Returns trimmed string.

Failure: Returns old string.

Remarks

None.

Example

$Str = StrNew(@'\0', 15);
$Str[0] = 'A'; // Set first char to A
$Str[1] = 'B'; // Set second char to B
say $Str; // Prints: AB
say StrLen($Str); // 15
 
// Lets fix the string so its no longer 15 in size
// but fits all way to null term so 2 in size
say "Trimming...";
$Str = TrimToNull($Str);
say $Str; // Prints: AB
say StrLen($Str); // 2
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox