Home  Contents

string.fix

String Core4 Lua Commands

SYNOPSIS

  1. result = string.fix(s, len, pad)
  2. result = string.utf8fix(s, len, pad)

DESCRIPTION

Returns the string s with its length made exactly len characters. If s is shorter than len, additional characters with the byte code pad are appended. Should s be longer than len, the string is truncated.

The second form works the same as the first, but assumes s is UTF8 encoded. It also accepts the full unicode codepoint range for pad. The returned string contains exactly len UTF8 characters, but may contain more than len bytes.

RETURN VALUE

Returns a string.

EXAMPLE

>  > 
print(string.fix("12345", 10, 42)) print(string.fix("12345", 3, 42))
12345***** 123