--中文字符判断
function stringIsHaveChinese(str,iType)
if str == nil then
return false
end
if iType == 1 then
-- local s = string.gsub(str, "^.", "")--标点符号
-- if #s > 0 then
-- luaPrint("00 s = "..s)
-- return false
-- end
local s = string.gsub(str, "%P", "")--标点符号
if #s > 0 then
luaPrint("11 s = "..s)
return false
end
local s = string.gsub(str, "%C", "")--控制符
if #s > 0 then
luaPrint("22 s = "..s)
return false
end
local s = string.gsub(str, "%A", "")--数字
if #s > 0 then
luaPrint("33 s = "..s)
return false
end
local s = string.gsub(str, "%D", "")--数字
if #s > 0 then
luaPrint("44 s = "..s)
return false
end
local s = string.gsub(str, "%W", "")--数字
if #s > 0 then
luaPrint("55 s = "..s)
return false
end
local s = string.gsub(str, "%S", "")--数字
if #s > 0 then
luaPrint("66 s = "..s)
return false
end
-- local s = string.gsub(str, "[^~!?。,、|:;’;【】《》]", "")--数字
-- local s = string.gsub(str, "[^~!?。,、|;‘]", "")--数字
-- if #s > 0 then
-- luaPrint("77 s = "..s)
-- return false
-- end
end
local l = #string.gsub(str, "[^\128-\191]", "")
luaPrint("l --------------- "..l)
return (l ~= 0)
end
代码如上,一般正常的可以用。