in reply to Re: Substituting literal strings for escape characters
in thread Substituting literal strings for escape characters

That contains a bug:

The input string:  \\n should be interpreted as:  \n (as in, the backslash escapes the backslash) but in your case, it becomes a backslash followed by a newline.

The solution is:  s/(\\.)/qq["$1"]/eegs

Btw, the reason "$1"/e isn't sufficient is because when using /e it doesn't interpolate before evaluating, so the expression really becomes "$1" which is identical to $1 - no change happens at all.

With qq["$1"]/ee however it'll interpolate $1 into a double-quoted string the first time, and then evaluates that double-quoted string

•Update: to also support multi-char escapes:

s/(\\(?:\d{1,3}|x[a-fA-F\d]{1,2}|x\{\w*\}|c.|N\{\w*\}|.))/qq["$1"]/eeg +s
(not fully tested)