Reputation: 1108
How can I, using Javascript, turn this:
RUA CALLOUSTE GULBENKIAN N.\XBA\ 42 3\XBA\ ESQ
into this:
RUA CALLOUSTE GULBENKIAN N.º 42 3º ESQ
Is there some method that does this? Because otherwise I would have to predict all the special characters that could appear to replace them.
EDIT:
Tried using String(text)
after lower-casing the x and it still doesn't decode the character. Anyone knows any other way?
Upvotes: 0
Views: 313
Reputation: 3144
You can use String()
to do so, however you'll need to lowercase the X in the escapes (resulting in \xBA
)
Example code (tested in Chrome dev console):
> String('RUA CALLOUSTE GULBENKIAN N.\xBA\ 42 3\xBA ESQ');
< "RUA CALLOUSTE GULBENKIAN N.º 42 3º ESQ"
Source (MDN, last one in the table)
Upvotes: 1