This is  called by the functions that generate ECL for unicode strings.  As it stood the only character in a unicode string being quoted was a single quote - \n and other control characters weren't.

Possibly this function should be renamed/removed and call rtlUnicodeToUtf8X instead.