AnsweredAssumed Answered

Velocity: Escape unicode

Question asked by Markus Bianchi on Mar 5, 2019
Latest reply on Mar 6, 2019 by Markus Bianchi

What would be the best / most efficient way in velocity to automatically convert (ideally all or at least some) special characters to the equivalent unicode escape code, e.g.

 

Ä -> \u00c4,

ä -> \u00e4

Ö -> \u00d6

ö -> \u00f6

Ü -> \u00dc

ü -> \u00fc

ß -> \u00df

 

I haven't found some built-in function that can automatically convert these characters and a simple

 

$str.replace("ä", "\u00c4")

 

doesn't seem to work in some initial tests and would also mean that I have to replace each character separately (unless there is some way to replace multiple characters in one go).

 

Sanford Whiteman maybe?

 

Many thanks,
Markus

Outcomes