You are here: Lua Scripting Resources eGuide > Lua Scripting API Reference Guide > String Library Extension > usub

15.3 usub

string.usub(str, startpos, endpos) 
or

str:usub(startpos, endpos)

This routine returns a substring of str. It is the Unicode version of string.sub. It accounts for multi-byte characters encoded in UTF-8.

Caution

This is an expensive routine. It allocates a temporary memory buffer during its operation.

Listing 15.1: Examples for string.usub()

print(string.usub("abc", 1, 1)) -- prints "a" 
print(string.usub("abc", 2, 2)) -- prints "b"
print(string.usub("abc", 2, 3)) -- prints "bc"

Introduced in platform.apiLevel = '1.0'