C
C#8mo ago
stigzler

❔ How to stop WebClient.DownloadString encoding apostrophies?

Does anyone know why WebClient.DownloadString encodes certain characters (e.g. apostrophe) even when .Encoding set to UTF8? E.g. "If you don't shoot fast enough" comes back as: "If you don't shoot fast enough"
6 Replies
nathanAjacobs
nathanAjacobs8mo ago
Isn't ' an html escape character? Are you downloading a wep page? If so, that's probably the text is in the actual html
stigzler
stigzler8mo ago
Not sure - downloading from an API - guess it must be html encoding as I'm getting the above text directly via the VS debugger from the direct result of the DonwloadString Method
stigzler
stigzler8mo ago
Yep - fixed it with HtmlDecode. Thanks, dude
Angius
Angius8mo ago
Also: don't use WebClient, it's deprecated, use HttpClient instead
Accord
Accord8mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.