how to ignore tashkeel character counting in text wrapping in corona sdk?

I’m doing text wrapping (to separate long string into lines) in corona

function wrap(str, limit, indent, indent1) indent = indent or "" indent1 = indent1 or indent limit = limit or 72 local here = 1-#indent1 str = replacePartOfString(str,"\*","\n") return indent1..str:gsub("(%s+)()(%S+)()", function(sp, st, word, fi) if fi-here \> limit then here = st - #indent return "\n"..indent..word end end) end local someString = " This is intended for strings without newlines in them (i.e. after reflowing the text and breaking it into paragraphs.) This is intended for strings without newlines in them (i.e. after reflowing the text and breaking it into paragraphs.) This is intended for strings without newlines in them (i.e. after reflowing the text and breaking it into paragraphs.) This is intended for strings without newlines in them (i.e. after reflowing the text and breaking it into paragraphs.) " print\_r(string.split(wrap(someString,70,"",""),"\n"))

it works fine with english and arabic, but the only problem is it counts the tashkeel in arabic as letters, what is the best way to ignore these characters and not count them? I want to keep them, but not count them in text wrapping.

aTov5.jpg

 

 

Hi @3denator,

Your best approach would be to use the UTF-8 plugin. This can help you work with special characters and process the “length” of strings in very customized ways. In particular, I think the “utf8.width()” function will be helpful:

https://docs.coronalabs.com/plugin/utf8/width.html

Best regards,

Brent

Hi @3denator,

Your best approach would be to use the UTF-8 plugin. This can help you work with special characters and process the “length” of strings in very customized ways. In particular, I think the “utf8.width()” function will be helpful:

https://docs.coronalabs.com/plugin/utf8/width.html

Best regards,

Brent