| 12345678910111213 |
- local function insert(str, i, o)
- i = utf8.offset(str, i)
- local first_half = str:sub(1, i - 1)
- local latter_half = str:sub(i, -1)
- return first_half .. o .. latter_half
- end
- local function tests()
- local res = insert("ação", 5, "!")
- print(('insert("ação", 5, "!") --> %s'):format(res))
- end
- tests()
|