Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

HTML Canvas - Add UNICODE or HTML Entity etc to Dynamic Text Field?

Engaged ,
Mar 20, 2022 Mar 20, 2022

How do I add UNICODE or HTML Entity etc to a dynamic text field??

 

E.g. 

root.streakAngle.text = streakAngle + '°';

  doesn't render ° as a degree symbol.

544
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , Mar 20, 2022 Mar 20, 2022

Hi.

 

There are several ways of doing this. Here's just a suggestion:

// "003E" is the unicode without the "U+" part
this.yourTextField.text = String.fromCharCode(parseInt("003E", 16));

 

This answer may give you more ideas:

https://stackoverflow.com/questions/17267329/converting-unicode-character-to-string-format

 

Regards,

JC

Translate
LEGEND , Mar 21, 2022 Mar 21, 2022

To include a Unicode character in a Javascript string, just use a Unicode escape sequence:

root.streakAngle.text = streakAngle + "\u00B0";
Translate
Community Expert ,
Mar 20, 2022 Mar 20, 2022

Hi.

 

There are several ways of doing this. Here's just a suggestion:

// "003E" is the unicode without the "U+" part
this.yourTextField.text = String.fromCharCode(parseInt("003E", 16));

 

This answer may give you more ideas:

https://stackoverflow.com/questions/17267329/converting-unicode-character-to-string-format

 

Regards,

JC

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 21, 2022 Mar 21, 2022
LATEST

To include a Unicode character in a Javascript string, just use a Unicode escape sequence:

root.streakAngle.text = streakAngle + "\u00B0";
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines