strlenutf8
Jump to navigation
Jump to search
Returns the number of characters in a UTF8-encoded string.
amount = strlenutf8(str)
Arguments
- str
- string - UTF8-encoded string.
Returns
- amount
- number - Number of characters in string.
Example
local amount = strlenutf8("Banana")
print("Count:", amount)
-- Count: 6
Details
For many operations, strlen may suffice. However; with non-English localization and accented player names, strlen may not return the correct amount of characters.
Non-accented Latin Characters:
print("Count:", strlen("The Lich King")) -- Count: 13
print("Count:", strlenutf8("The Lich King")) -- Count: 13
Accented Latin Characters:
print("Count:", strlen("Der Lichkönig")) -- Count: 14 (incorrect)
print("Count:", strlenutf8("Der Lichkönig")) -- Count: 13
See Also
Lua functions#String_Functions
External Links
World of Warcraft Community Site World of Warcraft Naming Policy
Unicode.org Unicode Names List Charts