check for non ascii characters in matlab

半腔热情 提交于 2019-12-25 08:16:32

问题


i have a result string that sometimes hold non ascii values. These non ascii values cause trouble so i need to check for their presence in the result string.

i tried with these two methods

if (regexpi(result , ^\s\x{20}-\x{7e}))
display('non ascii');
end

and

if any(result  < 128)
else
display('non ascii');
end

but it didn't work. Any help is greatly appreciated.


回答1:


small tweak to the above:

if all(result  < 128)
else
display('non ascii');
end

or

if any(result  > 127)
display('non ascii');
end


来源:https://stackoverflow.com/questions/10303634/check-for-non-ascii-characters-in-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!