utf8.insert()

Type Function
Library utf8.*
Return value String
Revision 2018.3333
Keywords utf8, UTF-8, Unicode, string, insert
See also utf8.remove()

Overview

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.

Syntax

utf8.insert( s, [idx,] substring )
s (required)

String. The source string.

idx (optional)

Number. The position at which to insert the substring.

substring (required)

String. The substring to insert.

Example

local utf8 = require( "plugin.utf8" )

local testStr = "♡ 你好,世界 ♡"

print( utf8.insert( testStr, 3, "UTF-8 " ) )  --> ♡ UTF-8 你好,世界 ♡