Skip to main content
Inspiring
March 20, 2022
Answered

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

  • March 20, 2022
  • 2 replies
  • 736 views

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.

    This topic has been closed for replies.
    Correct answer ClayUUID

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

    root.streakAngle.text = streakAngle + "\u00B0";

    2 replies

    ClayUUIDCorrect answer
    Legend
    March 21, 2022

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

    root.streakAngle.text = streakAngle + "\u00B0";
    JoãoCésar17023019
    Community Expert
    Community Expert
    March 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