detect non-ASCII char

J

Joy

Function IsGoodAcii(c As String) As Boolean
Dim ObjRegExp As Object

Set ObjRegExp = CreateObject("vbscript.regexp")
ObjRegExp.Global = True
ObjRegExp.Pattern = "[^\x20-\x7E]"
IsGoodAcii = ObjRegExp.test(c)
End Function

We use the above the code to detect non-ASCII char in Name
We have values like 'ABC', which are simply English characters. The above
checker works alright. However
for some computers, especially with non-English language, the above function
detects that the value is not ASCII.

Why it works OK for some machines but fails on others (with non-English
language)?
Thanks
 
J

Joy

I will try that.
thanks

Stephen Sanderlin said:
Try setting your pattern to [^A-Za-z 0-9
\.,\?'""!@#\$%\^&\*\(\)-_=\+;:<>\/\\\|\}\{\[\]`~]* instead of using the
\x matching.

--
Stephen Sanderlin, Project MVP
VP of Technology
msProjectExperts

For Project Server Consulting: http://www.msprojectexperts.com
For Project Server Training: http://www.projectservertraining.com

Read our blog at: http://www.projectserverhelp.com



Function IsGoodAcii(c As String) As Boolean
Dim ObjRegExp As Object

Set ObjRegExp = CreateObject("vbscript.regexp")
ObjRegExp.Global = True
ObjRegExp.Pattern = "[^\x20-\x7E]"
IsGoodAcii = ObjRegExp.test(c)
End Function

We use the above the code to detect non-ASCII char in Name
We have values like 'ABC', which are simply English characters. The above
checker works alright. However
for some computers, especially with non-English language, the above function
detects that the value is not ASCII.

Why it works OK for some machines but fails on others (with non-English
language)?
Thanks

.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top