--- title: string - Strings summary: A byte sequence. Lua 5.1 #text counts bytes, not UTF-8 characters. Concatenate strings with .. . section: reference kind: guide status: reference updated: 2026-10-26 tags: ["API","X4"] sources: ["https://wiki.egosoft.com/X4%20Foundations%20Wiki/Modding%20Support/","https://www.lua.org/manual/5.1/manual.html","https://luajit.org/ext_ffi_api.html"] --- ## Meaning A byte sequence. Lua 5.1 #text counts bytes, not UTF-8 characters. Concatenate strings with .. . ## Example ```lua local text = "ship" local upper = string.upper(text) local same = text:upper() local joined = text .. "_name" ``` **What happens:** upper = "SHIP", same = "SHIP", joined = "ship_name"; the original text remains "ship". This fragment does not print or write a log message. The values shown are the expected results of the example. ## Methods and related calls | Function | Returns | Purpose | | --- | --- | --- | | [string.byte](wiki:api-standard-string-byte-281cf317) | [`number`](wiki:type-number), ... | Returns numeric byte values for the selected string range. | | [string.char](wiki:api-standard-string-char-d6ca661d) | [`string`](wiki:type-string) | Constructs a string from numeric byte values. | | [string.find](wiki:api-standard-string-find-f077b0bb) | ([`number`](wiki:type-number), [`number`](wiki:type-number), ...) \| [`nil`](wiki:type-nil) | Returns match start/end positions followed by pattern captures, or nil when unmatched. | | [string.format](wiki:api-standard-string-format-6dd0b9fc) | [`string`](wiki:type-string) | Builds a string from a format specification and supplied values. | | [string.gmatch](wiki:api-standard-string-gmatch-de045990) | [`function`](wiki:type-function) | Returns a Lua-pattern match iterator; Lua patterns are distinct from PCRE regular expressions. | | [string.lower](wiki:api-standard-string-lower-45da4911) | [`string`](wiki:type-string) | Returns a lowercase copy; it is not a general Unicode case converter. | | [string.rep](wiki:api-standard-string-rep-61de1e05) | [`string`](wiki:type-string) | Returns a string repeated the requested number of times. | | [string.upper](wiki:api-standard-string-upper-dde50125) | [`string`](wiki:type-string) | Returns an uppercase copy; it is not a general Unicode case converter. |