Discriminate between upper and lower case characters (1 Viewer)

LanaR

Member
Local time
Tomorrow, 03:50
Joined
May 20, 2021
Messages
78
I'm working on a routine to strip out accented characters from a string and replace them with standard Latin characters.

The code does pretty much what I'm looking for, except that it doesn't seem to discriminate between upper and lower case characters. The code looks in part like;

Code:
 Select Case GrapeLetterCheck
                    
                            Case "ƒ"
                                GrapeLetterCheck = "f"
                            Case "Š"
                                GrapeLetterCheck = "S"
                            Case "š"
                                GrapeLetterCheck = "s"
                            Case "ß"
                                GrapeLetterCheck = "ss"
                            Case "Ä"
                                GrapeLetterCheck = "Ae"
                            Case "ä"
                                GrapeLetterCheck = "ae"
                                
                                ....
                                
End Select

For example, š with return S rather than s.

What do I need to change to get the code to make the distinction between Š and š (or any other upper/lower case characters)?
 

Minty

AWF VIP
Local time
Today, 17:50
Joined
Jul 26, 2013
Messages
8,842
I would use Asc() or chr() to get / compare the character code.

? Asc( "ƒ")
131
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 00:50
Joined
May 7, 2009
Messages
14,176
you can also use AscW() and ChrW().
 

LanaR

Member
Local time
Tomorrow, 03:50
Joined
May 20, 2021
Messages
78
Thanks, I was afraid the answer would be something like that
 

LanaR

Member
Local time
Tomorrow, 03:50
Joined
May 20, 2021
Messages
78
? Asc( "ƒ")
131

I know that's correct, as I just did a test. But according to all the tables I've found say

ASCII code 131 = â ( letter a with circumflex accent or a-circumflex )
ASCII code 159 = ƒ ( Function sign ; f with hook sign ; florin sign )

Which confuses me to no end 😵
 

Minty

AWF VIP
Local time
Today, 17:50
Joined
Jul 26, 2013
Messages
8,842
Try this one
1623670832117.png
 

LanaR

Member
Local time
Tomorrow, 03:50
Joined
May 20, 2021
Messages
78
Thanks. I'd just found something similar.

I'm still curious though, why the mismatch?
 

MarkK

bit cruncher
Local time
Today, 09:50
Joined
Mar 17, 2004
Messages
7,840
Check out the Option Compare statement at the top of your module.
Code:
'Option Compare Database
Option Compare Binary

Sub TestTextComparison()
    Debug.Print "a" = "A"
End Sub
If you change it to Option Compare Binary, then your upper and lower case characters will not be equal.
 

LanaR

Member
Local time
Tomorrow, 03:50
Joined
May 20, 2021
Messages
78
Thanks, I'll keep that in my pocket for the next time :)
 

Users who are viewing this thread

Top Bottom