pil-4th
pil-4th copied to clipboard
Wrong index
https://github.com/oitofelix/pil-4th/blob/417e4604cef776024c353fc1b3ae8652ffef3841/ex-4.6.lua#L11
This (and also in ex 4.4) should have the -1
in the call to utf8.offset
on the outside and not on the inside. Try this output and you will see:
-- Japanese example. jp = '私は日本語が分かります。' print(jp) print(insert(jp, 3, "少し"))
-- Chinese example. zh = "我學了四年了,可是很長的時間沒有練習。" print(zh) print(insert(zh, 4, "中文"))
-- Japanese example. jp = '私は少し日本語が分かります。' print(jp) print(remove(jp, 3, 2))
-- Chinese example. zh = "我學了中文四年了,可是很長的時間沒有練習。" print(zh) print(remove(zh, 4, 2))