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">
</head>
I'm at somewhat of a loss. Any ideas?
Edit: In firefox, going to View > Encoding shows both pages are in UTF-8.
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>
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With