How to declare "strings" accented strings?

Asked

Viewed 187 times

0

Lua is written in C logo shares the American Standard Code for Information Exchange "ASCII"

Accepts matrix key declaration with accent:

rafael = {}
rafael["é"]="eu"
print(rafael["é"])

--saída:     eu

But how to make string declaration "string" with accent ?

é="eu"      -- é possível ?
  • 2

    Even though I have no knowledge in prism I say that variable names with accents is always a bad idea. There is no advantage because they are internal names and only visible to the programmer and it is always another reason for possible problems with encodings.

  • 1

    Actually you want accented identifiers (bad idea, I agree with @Isac). Strings accents you’ve seen that work.

  • 1

    Do not use accents for variable names.

1 answer

1

Terminology. In his example é="eu", you would call é of a identifier or name.

Responding. A Lua code is divided into: grammar and syntax. Syntax depends on grammar (as the sole lexical objective, on the Moon). In Lua grammar it is only possible to enter the character is within comments and strings strings, because their productions do not care about all characters (only delimiters, if applicable).

Otherwise, it is not possible to enter the character is and answered. Moon has nothing to do with C.

Lexical definition of a Lua name (based on ECMA-357 2º):

Name ::

  • Namerepeat but no keyword

Namerepeat ::

  • Namestart
  • Namerepeat Namerepeat

Namestart ::

  • Any Latin letter (A-Z or a-z) in ASCII
  • _

Namepart ::

  • Namestart
  • Any type of ASCII

That is, an identifier consists of normal ASCII letters and/or _ (strokes) and optionally continues with digits. This is what the manual says.

  • When I wrote "derivative" I referred to the sources that are written in C. Not that she took C and modified.

  • @Rafaellemos Or did you mean implementation...

  • @Rafaellemos If you want to put é in an identifier, there are several alternatives: Javascript, XML, Java and blah.

  • Very good, javascript I already knew. The problem of writing Portuguese without an accent is that afterwards I get confused and I don’t even know if the word has an accent or not. It drives me crazy!

  • @Rafaellemos Actually, I’m not a fan of mixing Portuguese with codes. Maybe because one wants to vary in language from so much getting tired of the native. But, really, it seems that Español is better hueahueahuea Brinks slá

Browser other questions tagged

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