Mawu (Strings)

A string is a sequence of characters. In Duwa, Mawu (String) is a type that represents strings. It is used to represent text values. These strings are UTF-8 encoded.

Syntax

mawu x = "Hello, World!";

Examples usage

mawu x = "Hello, World!";
Khonso.lemba(x);

Escape Sequences

Duwa supports the following escape sequences in strings:

  • \" - double quote
  • \\ - backslash
  • \n - newline
  • \r - carriage return
  • \t - tab
  • \u{} - Unicode code point
mawu x = "Hello, \"World\"!";
mawu y = "Hello, \nWorld!";
mawu z = "Hello, \u{1F600}!";

Conversion to Mawu

To explicitly convert a value to a string, you can use the kuMawu function.

Nambala

Numbers are converted to their string representation.

mawu x = kuMawu(10);
Khonso.lemba(x); // "10"

Tsimikizi

zoona is converted to "zoona" and bodza is converted to "bodza".

mawu x = kuMawu(zoona);
Khonso.lemba(x); // "zoona"

Array

Arrays are converted to their string representation.

mawu x = kuMawu([1, 2, 3]);
Khonso.lemba(x); // "[1, 2, 3]"

Classes

Classes are converted to their string representation.

Munthu munthu = Munthu();
mawu x = kuMawu(munthu);
Khonso.lemba(x); // "Munthu"

Note: Convertion from other types to string is not supported yet. (If it works, it's a bug)

Methods

kumalizaNdi(mawuOsintha: mawu)→ mawu

Arguments

mawuOsintha
mawu

Returns

mawu

This method checks if the string ends with the given string.

peza(mawuOpeza: mawu)→ mawu

Arguments

mawuOpeza
mawu

Returns

mawu

This method finds the first occurrence of the given string in the string and returns it.

pezaZonse(mawuOpeza: mawu)→ string[]

Arguments

mawuOpeza
mawu

Returns

string[]

This method finds all occurrences of the given string in the string and returns them.

format(mawuOsintha: mawu)→ mawu

Arguments

mawuOsintha
mawu

Returns

mawu

This method formats the string with the given arguments.

kutalika()→ nambala

Returns

nambala

This method returns the length of the string.

gwirizana(mawuOsintha: mawu)→ nambala

Arguments

mawuOsintha
mawu

Returns

nambala

This method checks if the string matches the given regular expression.

maloMwa(source: mawu, value: mawu)→ mawu

Arguments

source
mawu
value
mawu

Returns

mawu

This method replaces all occurrences of the given string with the new string.

gawa(mawuOgawa: mawu)→ string[]

Arguments

mawuOgawa
mawu

Returns

string[]

This method splits the string by the given string and returns a list of strings.

yayambaNdi(mawuOsintha: mawu)→ mawu

Arguments

mawuOsintha
mawu

Returns

mawu

This method checks if the string starts with the given string.

toLowerCase()→ mawu

Returns

mawu

This method converts the string to lowercase.

kuNambala()→ nambala

Returns

nambala

This method converts the string to a number.

kuMawu()→ mawu

Returns

mawu

This method converts the string to a string.

toUpperCase()→ mawu

Returns

mawu

This method converts the string to uppercase.

chepetsa()→ mawu

Returns

mawu

This method removes whitespace from the beginning and end of the string.

chepetsaKuMapeto()→ mawu

Returns

mawu

This method removes whitespace from the end of the string.

chepetsaKuchiyamba()→ mawu

Returns

mawu

This method removes whitespace from the beginning of the string.