Minor

Keep the variables closer to the loop where they are used.
XXX: use regex to decode escapes

Not fully working yet, handles only \u[XX]XX and \N{XXX} ones, need to
handle other cases taken care by the old code. Has the side effect of
handling \nXX and \nXXX escapes.