Home > other >  How do I find the UTF-8 version of the Octal '\033c'
How do I find the UTF-8 version of the Octal '\033c'

Time:12-07

I am working on a Javscript project with the following code...

process.stdout.write('\033c');

The IJ tooltip says

Octal escape sequences are not allowed

So I am pretty sure I just need to convert the \033c to UTF-8 but since it is kind of a weird char I am not sure I am understanding things properly.

I tried this...

process.stdout.write("\\033c");

per this but it still has the same issue

CodePudding user response:

This has nothing to with UTF-8. \033c is supposed to be two characters: \033 (the ESC control character, code point U 001B) and c (a regular lower-case c).

The error says that octal escape sequences are not allowed, so let's use hex instead. Octal 33 converted to hexadecimal is 1B, so you can use \x1b*. In combination with the c you get \x1bc.

For more information, see the section about escape sequences on MDN.

*: You could also use \u001b instead of \x1b but for characters in the range of U 0000 to U 00FF it doesn't matter.

  • Related