## Description¶

Add multiple pad characters at the given side(s) of each string so that each output string is of total width of at least width. These functions may be used to center or left/right-align each string.

## Usage¶

stri_pad_both(
str,
width = floor(0.9 * getOption("width")),
use_length = FALSE
)

str,
width = floor(0.9 * getOption("width")),
use_length = FALSE
)

str,
width = floor(0.9 * getOption("width")),
use_length = FALSE
)

str,
width = floor(0.9 * getOption("width")),
side = c("left", "right", "both"),
use_length = FALSE
)


## Arguments¶

str

character vector

width

integer vector giving minimal output string lengths

pad

character vector giving padding code points

use_length

single logical value; should the number of code points be used instead of the total code point width (see stri_width)?

side

[stri_pad only] single character string; sides on which padding character is added (left (default), right, or both)

## Details¶

Vectorized over str, width, and pad. Each string in pad should consist of a code points of total width equal to 1 or, if use_length is TRUE, exactly one code point.

stri_pad is a convenience function, which dispatches to stri_pad_*.

Note that Unicode code points may have various widths when printed on the console and that, by default, the function takes that into account. By changing the state of the use_length argument, this function starts acting like each code point was of width 1. This feature should rather be used with text in Latin script.

See stri_trim_left (among others) for reverse operation. Also check out stri_wrap for line wrapping.

## Value¶

These functions return a character vector.

## Author(s)¶

Marek Gagolewski and other contributors

The official online manual of stringi at https://stringi.gagolewski.com/

Other length: %s\$%(), stri_isempty(), stri_length(), stri_numbytes(), stri_sprintf(), stri_width()

## Examples¶

stri_pad_left('stringi', 10, pad='#')
## [1] "###stringi"
## [1] "stringi*"     "*stringi*"    "*stringi**"   "**stringi**"  "**stringi***"
# center on screen: