Detecting foreign characters in string

nickthompson

Registered User.
Local time
Today, 21:58
Joined
Sep 13, 2010
Messages
18
Hi all

I have a report that uses a font called 'Denda New', but while the font supports many foreign characters, there are some that it doesn't support.

The report is opened from a form by clicking on a person's name. To get around the font problem I'm looking to add some code just before the report is opened to check the person's name for offending foreign characters, and if they're present then open a different report instead that uses Verdana (which does support those characters).

I would normally do this using the ASC function to check the Ascii code of each character as part of a loop. But that doesn't seem to work here. e.g. if i run ASC on an S with a cedilla underneath, it returns 83, which is the Ascii code for a normal capital S.

Any suggestions for how I can detect these characters please?

Many thanks

nick
 
I've found a solution to my own problem.

In case it helps anyone else, the problem is caused by some characters which are out of the normal Ascii range, and are actually two characters combined together. While the 'Asc' function doesn't recognise there, 'AscW' is another function that does. The function below can be run on each string to determine if it's got any of these characters in it.

Code:
Function IsArabicName(Name As String) As Boolean

    Dim x As Integer
    
    For x = 1 To Len(Name)
        If AscW(Mid(Name, x, 1)) > 256 Then
            IsArabicName = True
            Exit Function
        End If
    Next x
        
    IsArabicName = False
    
End Function
 

Users who are viewing this thread

Back
Top Bottom