Upgrade to Pro — share decks privately, control downloads, hide ads and more …

From String undump to String unescape

From String undump to String unescape

Tadashi Saito

July 18, 2019
Tweet

More Decks by Tadashi Saito

Other Decks in Programming

Transcript

  1. end

  2. From the document: Produces a version of str with all

    non-printing characters replaced by \nnn notation and all special characters escaped.
  3. 1. backslash + one character \n \t \\ 2. \x

    + 2 hex digits \x12 3. \u + 4 hex digits \u1234 etc etc...
  4. •Submitted about a year ago •Specs (including the name –

    most difficult part) were almost fixed! 🙌
  5. • undump-ed string must be wrapped with "…" like ‘”\u1234”’

    •Because String#dump always wraps with "..." String#undump Spec
  6. •A little dull to prepend / append ” •Both of

    the original use-case and my case don't need this behavior
  7. if self[0] == '"' && self[-1] == '"’ self else

    ‘"’ + self + ‘”’ end.undump Definition