Comparing strings

I have a complaint from an Italian user that the question and the answer appear to be the same, but are being marked wrong. In looking at the entered text, the correct is “Bene, grazie.” and the answer is “Bene, grazie.” They appear to be the same, but in looking at the length dim i As integer = Len(myAns) one is 13 and the other 14. What might cause this? Encoding? How do I prevent the problem?

TIA

Thanks, Jean-paul, but my app uses Trim to set the variables in the first place.

Trim won’t strip endOfLIne, just space.

No, Trim will strip all whitespace.

[quote=281100:@Roger Clary]I have a complaint from an Italian user that the question and the answer appear to be the same, but are being marked wrong. In looking at the entered text, the correct is “Bene, grazie.” and the answer is “Bene, grazie.” They appear to be the same, but in looking at the length dim i As integer = Len(myAns) one is 13 and the other 14. What might cause this? Encoding? How do I prevent the problem?

TIA[/quote]
Possibly composed vs not composed (or decomposed)

Some characters can be represented in 2 ways

  1. with two separate unicode code points
    for instance
    the first for a character that CAN have an accent grave applied (say an e)
    the second maybe for the combining accent grave
    so you get è as the end result

  2. as a SINGLE unicode code points that is “e with accent grave”

you’ll get 2 different counts for this case

visually they look the same

Here’s an example

  dim t as string = &u00e8
  dim t1 as string = "e" + &u0300
  
  if t = t1 then
     msgbox "equal"
   else 
     msgbox "not equal"
  end if

Now something the NEW TEXT type handles is EXACTLY this difference
Try this

  dim t as text = &u00e8
  dim t1 as text = "e" + &u0300
  
  if t = t1 then
     msgbox "equal"
   else 
     msgbox "not equal"
  end if

Precomposed vs. decomposed is a PITA. Once upon a time I really thought I was going senile because of this. Do a EncodeBase64 with the answer of the customer and write it to a log file. Then have the customer send it to you.

Text type takes care of precomposed and decomposed. But I doubt it is the issue here. Unless there are accented characters in some answers.

Anyway, I would tend to use Instr, so the trailing whatever would not interfere.