Encodes a multiline string into one line for Github Action output.
encode_string(string, join = FALSE)
A character vector.
Join vector into single string using encoded newline.
A character vector (of length 1 if join
).
This will only encode '%', '\n', '\r' as these will be automatically
decoded by Github when using the output via ${{ steps.<step_id>.outputs.<name> }}
. You can use utils::URLencode()
instead
of this function to also escape everything else problematic like (double)
quotes etc. but you will have to manually use utils::URLdecode()
to revert
this.
chrs <- c("100% This is some output with \n", "a new line")
encode_string(chrs)
#> Error in encode_string(chrs): could not find function "encode_string"
# encode some md (e.g. to post as comment)
md <- c("# Important PR Comment", " ", "This commit is great!")
encode_string(md, TRUE)
#> Error in encode_string(md, TRUE): could not find function "encode_string"