How to escape special characters?

Asked

Viewed 212 times

1

I need the output to be a special character of an arrow pointing to the right ( ) for example, whose Unicode code is U+1F812. I tried to write in various ways always with the \ or % preceding Unicode code (similar to writing a tab or line break) and getting the following error:

bash: syntax error near unexpected token `"\u2191"'

How should be the syntax for the output of these special characters and what UTF-8, UTF-32 etc. interfere with it?

2 answers

1

In Lua 5.3, you can use "\u{2191}". The keys are mandatory.

Lua 5.3 also includes a library utf8 and you can use utf8.char(2191).

0


You need to install the library with support for UTF-8, otherwise you won’t be able to use.

If you are going to do the installation by luarocks, check the library directory of Moon, the files may not be in the necessary directory.

$ luarocks install utf8
# ou
$ luarocks install lua-utf8

I recommend the first.

How to use?

utf8 = require "utf8"
seta = utf8.char(2191) -- Nos meus testes o valor 9658 retornou uma seta
print(seta)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.