如何在电晕sdk文本环绕中忽略tashkeel字符计数?

时间:2016-09-17 10:21:39

标签: android ios lua 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"))

它适用于英语和阿拉伯语,但唯一的问题是它将阿拉伯语中的塔什凯尔称为字母,忽略这些字符而不计算它们的最佳方法是什么?我想保留它们,但不要用文字包装来计算它们。

image

2 个答案:

答案 0 :(得分:1)

string.gsub()适用于字符串的字节,而不适用于字符。字符串包含Unicode文本时有所不同。 使用utf8库来获取字符。

答案 1 :(得分:0)

塔什龙骨的阿拉伯语unicode ID为:

[\x{064B}-\x{0650}],[\x{0618}-\x{061A}],[\x{0652}-\x{0653}],[\x{0652}-\x{0653}]

您可以使用任何代码将其删除。

问候