Lua Programming/case conversion

From Wikibooks, open books for an open world
Jump to navigation Jump to search

The lua string library provides the string.upper and string.lower functions for converting strings to uppercase or to lowercase:

string.lower[edit | edit source]

Usage[edit | edit source]

string.lower(STRING)

Description[edit | edit source]

The string.lower function returns a lowercase version of the STRING argument. This function converts all letters to lowercase in the returned string. Only the returned string is converted, the provided argument remains unchanged:

print (string.lower("I Like Apples"))

string.upper[edit | edit source]

Usage[edit | edit source]

string.upper(STRING)

Description[edit | edit source]

The string.upper function returns an uppercase version of the STRING argument. This function converts all letters to uppercase in the returned string. Only the returned string is converted, the provided argument remains unchanged:

print (string.upper("I Like Apples"))

These functions are affected by the locale settings[edit | edit source]

These function are affected by the following locale environment variable settings.

  • LC_ALL
  • LC_CTYPE