Core Function TrimToNull

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
UberFoX (Talk | contribs)
(Created page with "<pre> TrimToNull( <string> ) </pre> === Description === Strip all zero chars (nulls) from the end of a string. === Parameters === ==== string ==== The string to trim. === R...")

Latest revision as of 10:14, 19 September 2015

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