I've been doing some research on declaring character encodings, and thought I'd look at what google do on their homepage.
On the google homepage <head> tags they have:
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
But then in the http headers it's:
Content-Type: text/html; charset=ISO-8859-1
I'm interested in understanding they would do this.
Edit: It happens on https://google.com/ I'm certain I spotted this in the browser earlier, but now I get the expected content-type: text/html; charset=UTF-8. However, when I send a request from postman I get the same http header as before.
It appears that the response is based on the user-agent request header. If I send a request with a missing or unusual user-agent the response header is ISO-8859-1. Still not sure why this is done and would be interested in an explanation.
Related
I have an old web site in French tha I want to preserve and whose html files were encoded in iso-8859-1. All html files included
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
in the <head> element, however the host of my website changed something in the configuration an now pages are sent from their server with an HTTP header including
content-type: text/html; charset=UTF-8
and unfortunately someone decided this would override the <meta> information.
Do I have to trans-code all my html files to UTF-8 or is there a faster solution?
Update
In fact the charset was added to the http header's content-type field only for html content issued by php, not for pure html files. I'll put the solution I adopted as an answer.
Your options:
Transcode the files
Persuade whomever changed the server configuration to change it again
Change servers
Run all every request through a server side script which outputs a different Content-Type header and then outputs the HTML (which accounting for cache-control headers)
Took me a while to realize the problem occurs only for .php files. The fix I chose is the following: I added the line
ini_set('default_charset', NULL);
at the beginning of every php files. A bit tedious but seems reasonable to me.
I currently put this <meta cache-control: public ETag: "v019" />
in the <head> just under the <title>, but keep getting Errors in the W3 validator.
What is the format and where do I put this in my HTML5 file?
An ETag isn't useful unless it is in a real HTTP header. It shouldn't be in your HTML document at all.
That said, the syntax for an HTML meta tag with a simulation of an HTTP header is:
<meta http-equiv="cache-control" value="public">
<meta http-equiv="ETag" value=""v019"">
cache-control and ETag are not accepted values for it in HTML 5. You would need to be using HTML 4 or earlier (although it would still be pointless).
I have the language pack for Japanese characters installed onto my computer so I can practice but when I put it into an html file and uploaded it to the server that I'm using, it displays as this weird gibberish.
The encoding is in utf-8 but it still appears this way?
http://kotonii.com/katakana.html
You should check your server configuration. It does not have a "charset" in the "Content-type" header and in absence of this, the browser will use its own default charset (usually iso-8859-1, a.k.a. 'Latin1').
Your server has this:
Content-Type: text/html
It should be this, for your browser to decode it as utf-8:
Content-Type: text/html; charset=utf-8
You can also add this to the page's <head> section, it helps if you are viewing it in the browser as a local file (but shouldn't be a substitute for the HTTP header):
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
What Content-Type does SendGrid set in the header by default?
I have an issue where html email going thru Sendgrid is not being formatted properly.
In the email header I see
MIME-Version: 1.0
Content-Type: text/plain
and then the following is rendered in any email client, standalone or web based.
This is a multi-part message in MIME format.
--------------e21a5bffb444e61b8e8a30240210d506
Content-Type: text/html; charset=UTF-8; format=flowed
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
etc etc
Shouldn't the Content-type in the header be multipart/mixed or similar to properly render the html and display images?
How is this changed?
Can it be changed somehow by the actual html being sent to SendGrid's server?
Any feedback appreciated!
The library you are using is hardcoding the content-type to be text/plain. In the smtp/mailer/SMTPMailer.as source on line 135:
writeUTFBytes ("Content-Type: text/html; charset=UTF-8; format=flowed\r\n");
This library doesn't look like it's extremely robust, it's lacking documentation, and it's 6 years old. You may want to try to find a different solution.
Everyone knows what http stands for Hyper Text Transport Protocol for the HTML (Hyper Text Markup Language). What the heck does equiv stand for: equivalent? What does it mean. I know it can be used to specify refresh values and charset/encoding but that's no closer to understanding what it means.
equiv does stand for equivalent. It's equivalent to the HTTP response header. For example, these two are the same
<META http-equiv="content-type" content="text/html; charset=UTF-8">
Content-Type: text/html; charset=utf-8
The HTTP header should be used over the http-equiv meta tag though.
http://cyberprodigy.blogspot.com/2009/08/what-does-http-equiv-stands-for.html
Yes, equivalent. As in, it has an effect equivalent to specifying the given HTTP header.