TextField.KeyDown event is US-ASCII, TextField.Text is UTF-8 ?!?

I discovered something that seems odd today: The string that is returned via TextField.KeyDown is encoded as US-ASCII, but when getting the string from TextField.Text, it’s encoding is UTF-8. I’m typing a single character into the TextField)

Can someone explain why they’re different?

I’m on a Mac, running 2015r2.

Thanks!

US-ASCII is a subset of UTF-8

[quote=187767:@John McKernon]I discovered something that seems odd today: The string that is returned via TextField.KeyDown is encoded as US-ASCII, but when getting the string from TextField.Text, it’s encoding is UTF-8. I’m typing a single character into the TextField)

Can someone explain why they’re different?

I’m on a Mac, running 2015r2.

Thanks![/quote]

If you type an accented character or UTF-8 symbol such as “à”, it returns an UTF-8 string.

Since US-ASCII is a subset of UTF-8, does that mean I don’t need to convert it to UTF-8 before comparing it to another string that is UTF-8?

Text comparison is encoding-savvy. You wouldn’t need to convert it anyway.

Ah, I’d forgotten that, thanks!