Languages
[Edit]
EN

TypeScript - insert unicode character to string

0 points
Created by:
Dollie-Rutledge
806

In this article, we are going to look at how to insert Unicode characters to string in TypeScript.

There are three different ways how to do it:

  • with escape character e.g. \u03c0 that is equal to π,
  • by pasting character directly to string,
  • by converting codes to a string.

Quick solution:

Note: it is important to put 4 digits after \u.

More complicated example

Edit

Space is represented by 0x20 (in hex) or 32 (in dec). It is necessary to add 2 additional zeros before code (e.g. \u0020).

Marked inserted Unicode characters: π and \u03c0 are \u0020 equal.

References

Edit
  1. List of Unicode characters - Wikipedia
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join