I have some text I must’ve downloaded somewhere along the way which, when put into a string and displayed in a textarea suddenly starts doing ThIs,SoRt Of. It’s not every other letter, more random, but it’s like it’s changing point-size or font or something.
I’ve run it through an encoding bit, like this – s = s.DefineEncoding(Encodings.UTF8) – but it doesn’t change anything. I’ve iterated through the string building a new string with the characters that are <255 ascii value and that worked except … I lost smart quotes, etc.
I don’t really understand character encoding though I’ve grappled with it many times in the past. I’m too dumb I guess, or too old. Or too lazy to look carefully at the details. I just want a way to programmatically clean this whackiness out of this particular string and others like it.
DefineEncoding does not change things, it is only promise, by doing it then your saying, hey I got this string here and I know its this encoding, and I want to stamp it with promise that it is that encoding.
Now if your promise is incorrect then you will get bad result.
There are a couple smart apostrophes/quotes in there but, yeah, it’s mostly just ASCII. So how’s come I’m getting that crazy printing? Mystifying. I know I can do some workarounds but I’d like to solve this puzzle.
I looked closer and it’s little/big, little/big every other letter pattern. Could I be tapping into a crazy font that does this? It begins halfway through the text.
Okay, I did some work with fonts and now the problem has disappeared. I’m not sure why or how but it seems the System font may have been giving goofy results. Just a guess.
Anyway, I’m happy now … until the WHACKY FONTS rear their ugly heads again.