22nd September 2023 at 12:14pm
purpose | apply JavaScript string encoding to a string, see also the similar jsonstringify |
---|---|
input | a selection of titles |
suffix | R =Introduced in v5.1.23 optionally, the keyword rawunicode |
output | the input with JavaScript string encodings applied |
Learn more about how to use Filters
Introduced in v5.1.14The following substitutions are made:
Character | Replacement | Condition |
---|---|---|
\ | \\ | Always |
" | \" | Always |
' | \' | Always |
Line feed (0x0a) | \n | Always |
Carriage return (0x0d) | \r | Always |
Characters from 0x00 to 0x1f, except listed above | \x## where ## is two hex digits | Always |
Characters from 0x80 to 0xffff | \u#### where #### is four hex digits | If rawunicode suffix is not present (default) |
Characters from 0x80 to 0xffff | Introduced in v5.1.23 Unchanged | If rawunicode suffix is present |
Introduced in v5.1.23 If the suffix rawunicode
is present, Unicode characters above 0x80 (such as ร, รค, รฑ or ๐) will be passed through unchanged. Without the suffix, they will be substituted with \u
codes, which was the default behavior before 5.1.23. Characters outside the Basic Multilingual Plane, such as ๐ and other emojis, will be encoded as a UTF-16 surrogate pair, i.e. with two \u
sequences.