test
test

Reputation: 427

How to get degree symbol in a string?

I have a constant declared in typescript file as mentioned below.

const PASS_SPN_TXT = [ { name: 'PASS V C' },
    { name: 'PASS. T12 C' }];

In actual I want the names as PASS V degree symbol C and PASS.T12 degree symbol C. How to get degree symbol in a string.

Upvotes: 1

Views: 6437

Answers (2)

pooley1994
pooley1994

Reputation: 973

The accepted answer did not work for me. for some reason I ended up with literally:

...
'System Temp (\xB0C)'
...

What worked for me though (based on this answer )

...
'System Temp (°C)'
...

Upvotes: 0

PersyJack
PersyJack

Reputation: 1964

Or use hexadecimal code \xB0 like this:

const PASS_SPN_TXT = [ { name: 'PASS V \xB0C' },
    { name: 'PASS. T12 \xB0C' }];

Upvotes: 8

Related Questions