I basically took a html file that someone made and made a new MVC app and put it into a view, but now I get issues with apostrophes and other characters appearing like, "he’s a cat".
I’m comparing opening the original html file on the disk in the browser, and running the MVC application which is in my local IIS. Same browser.
The HTML in the <head> section appears to be the same in both when I do view source:
<!DOCTYPE html>
<html class="no-js">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Cats</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/style.min.css" rel="nofollow noreferrer noopener">
</head>
I’m at somewhat of a loss. Any ideas?
Edit: In firefox, going to View > Encoding shows both pages are in UTF-8.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
I’ve solved it, this is actually an issue with the way MVC was creating the HTML. I added the following to the web.config and it resolved the issue:
<globalization
fileEncoding="utf-8"
requestEncoding="utf-8"
responseEncoding="utf-8"
culture="en-US"
uiCulture="en-US"
/>
under <system.web>
Method 2
That’s the character output when a right-single-quote is sent in ISO-8859-1 rather than UTF-8. In the head you’re specifying ISO-8859-1 encoding so this is being misinterpreted. Your options are to use the HTML encoded value ’ or, as you’ve seen yourself, change your encoding to UTF-8.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0