com.twitter.conversions.string
Quote a string so that unprintable chars (in ASCII) are represented by C-style backslash expressions.
Quote a string so that unprintable chars (in ASCII) are represented by
C-style backslash expressions. For example, a raw linefeed will be
translated into "\n"
. Control codes (anything below 0x20)
and unprintables (anything above 0x7E) are turned into either
"\xHH"
or "\\uHHHH"
expressions, depending on
their range. Embedded backslashes and double-quotes are also quoted.
a quoted string, suitable for ASCII display
For every section of a string that matches a regular expression, call
a function to determine a replacement (as in python's
re.sub
).
For every section of a string that matches a regular expression, call
a function to determine a replacement (as in python's
re.sub
). The function will be passed the Matcher object
corresponding to the substring that matches the pattern, and that
substring will be replaced by the function's result.
For example, this call:
"ohio".regexSub("""h.""".r) { m => "n" }
will return the string "ono"
.
The matches are found using Matcher.find()
and so
will obey all the normal java rules (the matches will not overlap,
etc).
the regex pattern to replace
a function that takes Regex.MatchData objects and returns a string to substitute
the resulting string with replacements made
Turn a string of hex digits into a byte array.
Turn a string of hex digits into a byte array. This does the exact
opposite of Array[Byte]#hexlify
.
Unquote an ASCII string that has been quoted in a style like
#quoteC
and convert it into a standard unicode string.
Unquote an ASCII string that has been quoted in a style like
#quoteC
and convert it into a standard unicode string.
"\\uHHHH"
and "\xHH"
expressions are unpacked
into unicode characters, as well as "\r"
, "\n"
,
"\t"
, "\\"
, and '\"'
.
an unquoted unicode string