Type Function Library utf8.* Return value String Revision Release 2022.3683 Keywords utf8, UTF-8, Unicode, string, insert See also utf8.remove()
Inserts a substring into s
. If idx
is specified, inserts substring
before the character at this index; otherwise substring
will concatenated onto s
. Note that idx
can be negative.
utf8.insert( s, [idx,] substring )
String. The source string.
Number. The position at which to insert the substring.
String. The substring to insert.
local utf8 = require( "plugin.utf8" ) local testStr = "♡ 你好,世界 ♡" print( utf8.insert( testStr, 3, "UTF-8 " ) ) --> ♡ UTF-8 你好,世界 ♡