Skip to content
Paolo Angeli edited this page Oct 20, 2019 · 13 revisions

Strings in Jai are a simple standard array collection of Unicode UTF8 characters.

Strings are not null-terminated like in the C language.

To use Jai strings with external libraries that need null-terminated strings some workarounds are necessary.

Escape codes

To insert into the strings special characters, or foreign characters not supported by the editor in use (eg. for internationalization), or to create effects on the console are available several special escape codes.

Esc Description
\0 NUL ASCII character for null-terminated strings
\n Newline character
\t Tab character
\r Carriage return character
\" Double quotes character
\\ Backslash character
\e[...m Escape sequence
\xnn Character code addressed by a hexadecimal value
\dnnn Character code addressed by a decimal value
\unnnn Character code addressed by Unicode 16 bit hexadecimal value
\Unnnnnnnn Character code addressed by Unicode 32 bit hexadecimal value

Escape sequences are used to produce formatted output effects on the terminal console.

A simple effect on the console's output can be achieved in this way:

ESC_RED :: "\e[31m";
ESC_STD :: "\e[0m";

print ("This value is %IMPORTANT !%, ESC_RED, ESC_STD);

But be warned that many terminal emulators and console programs don't support escape sequences very well and some are better than others specially for true colors.

References


Youtube stream 2018/06/06

Types, constants and variables

  • Variables and assignments
  • Language data types
  • Simple user-defined data types
  • Expressions and operators
  • Type-casting
  • Pointers

Flow control

Procedures and functions

  • Declarations
  • Arguments / Parameters
  • Return values
  • Overloading / Polymorhism
  • Advanced features
  • Lambdas

Aggregated data types

  • Arrays
  • Strings
  • Composition of Structs

Advanced features

Clone this wiki locally