std-string-xxx-pad-char


Synopsis

(std-string-left-pad-char <str> <len> <fill-char>)

(std-string-right-pad-char <str> <len> <fill-char>)

Description

They justify a string to the left or right, so that the resulting string is exactly len characters long.

STD-STRING-LEFT-PAD-CHAR adds the fill character at the end.

STD-STRING-RIGHT-PAD-CHAR adds the fill character at the beginning.

Simplier justifiers like strfil can be implemented as

(defun strfil (s len) (std-string-right-pad-char s len " "))

which is the same as (str-rpad s len)

Examples

(std-string-left-pad-char (rtos 1.0) 6 " ")   => "1.0   "
(std-string-right-pad-char (rtos 1.0) 6 "-")  => "---1.0"
(std-string-left-pad-char "0001" 3 " ")       => "000"
(std-string-right-pad-char "1000" 3 " ")      => "100"

Arguments

str: a string.

len: a positive integer number.

fill-char: a string with one character. If more only the first is taken as fill character.

Return Value

A string.

Side Effects

None.

Module

(std-require 'STDSTR)

Defined in STDSTR