escape-strings: Add a tag-payload word to make a string payload and tag.

handle-patch-and-put
Doug Coleman 2018-07-21 15:18:29 -05:00
parent 279acbc53e
commit 12918ae2a5
1 changed files with 3 additions and 0 deletions

View File

@ -28,6 +28,9 @@ IN: escape-strings
: escape-strings ( strs -- str ) : escape-strings ( strs -- str )
[ escape-string ] map concat escape-string ; [ escape-string ] map concat escape-string ;
: tag-payload ( str tag -- str' )
[ escape-string ] dip prepend ;
: escape-simplest ( str -- str' ) : escape-simplest ( str -- str' )
dup { CHAR: ' CHAR: " CHAR: \r CHAR: \n CHAR: \s } counts { dup { CHAR: ' CHAR: " CHAR: \r CHAR: \n CHAR: \s } counts {
{ [ dup { CHAR: ' CHAR: \r CHAR: \n CHAR: \s } values-of sum 0 = ] [ drop "'" prepend ] } { [ dup { CHAR: ' CHAR: \r CHAR: \n CHAR: \s } values-of sum 0 = ] [ drop "'" prepend ] }