What is the definition of "coding agnostic"?
The same byte value in a string can represent different characters depending on the character encoding used for that string. For example, the same value \177
can represent β
in Code page 437 or Β±
in Windows 1252 .
Lua makes no assumptions that the encoding of a given string and ambiguity should be resolved at the script level; in other words, your script needs to know whether to process a sequence of bytes as the Windows 1252
, Code page 437
, UTF-8
or something else-encoded string.
source to share
Essentially, a Lua string is a counted sequence of bytes. If you are using Lua string for binary data, the concept of character encoding is irrelevant and does not interfere with binary data. So the string is code-agnostic.
The standard string library has functions that treat string values ββas text β an uncountable sequence of characters. There is no text other than encoded text. The encoding maps a member of a character set to a sequence of bytes. The string must have bytes for zeros or more of such encoded characters. To understand a string as text, you must know the character set and encoding. To use string functions, the encoding must be compatible with os.setlocale()
.
source to share