Skip to content
Advertisement

Replace Unicode escapes with the corresponding character

I’m trying to convert code points, such as u00FC, to the character it represents.

JavaScript

An example to explain what I mean:

First Console line: Input: Hallu00F6

Second Console line: And Now: Hallö

EDIT: Because sometimes it didn’t work with multiple Unicodes in The Trombone Willy’s answer, here is the Code fixed:

JavaScript

Advertisement

Answer

Joao’s answer is probably the simplest, but this function can help when you don’t want to have to download the apache jar, whether for space reasons, portability reasons, or you just don’t want to mess with licenses or other Apache cruft. Also, since it doesn’t have very much functionality, I think it should be faster. Here it is:

JavaScript

I hope this helps! (You don’t have to give me credit for this, I give it to public domain)

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement