Hello!
i am reading the chapter Build an ESP8266 Web Server and it works! But I don`t get the html page to show the Swedish letters å,ä,ö correct. I have tested with : client.println(“<head><meta http-equiv=“Content-Type” content=“text/html; charset=utf-8” />”); and also: client.println(“<meta http-equiv=“Content-Type” content=“text/html; charset=utf-8” />”); So any help would be grateful! Anders
// Display the HTML web page
client.println(“<!DOCTYPE html><html>”);
client.println(“<head><meta name=\”viewport\” content=\”width=device-width, initial-scale=1\”>”);
client.println(“<head><meta http-equiv=“Content-Type” content=“text/html; charset=utf-8” />”);
client.println(“<link rel=\”icon\” href=\”data:,\”>”);
Hello! I have also tryed with : client.println(“<head><meta http-equiv=“Content-Type: text/plain; charset=ISO-8859-1” />”); And it didn`t work eighter
Hi.
I think you should use the HTML entities instead of the characters.
Here are the HTML entities for the Swedish characters: https://usefulwebtool.com/characters-swedish
Try it and tell me if it works.
Regards,
Sara
Hello Sara! And thank`s for your fast reply! Yes I have used it to get it to work. But i wanted it to work just by typing the Swedish characters. I will use this soulution now and meanwhile I try to find a solution how to solve this.
Regards,
Anders
Hi Anders.
You can also try taking a look at some of the suggestions in this discussion: https://stackoverflow.com/questions/1365526/swedish-characters-and-utf-8.
Some of them, you already tried them. But, this can have something that might help.
Regards,
Sara
Hi Sara!
I have been testing this and load another example DS18B20 Async Web Server. And if you there use this <!DOCTYPE html>
<html lang=”sv”>
<head>
<meta charset=”utf-8″/>
Then you are able to use å,ä,ö as characters.
So something with the client.println seems to make it not to work.Both of them is stated as html5 so you should get both of them to work. I will continue to find a solution for this.
Helllo Sara! It is someting wrong with my quotas. If I look at view-source I get this:
<meta http-equiv=“Content-Type†content=“text/html; charset=utf-8†/>
<meta name=”viewport” content=”width=device-width, initial-scale=1″>
So I copied the quotas from the second lline and past it in. But then it dosen`t when I try to compile it I get a fault expected ‘)’ before ‘Content’
Regards Anders
Hi.
Can you show me the lines of code where you get the error?
That error means that you have a ) missing somewhere in your code.
Regards,
Sara
// Display the HTML web page
client.println(“<!DOCTYPE html><html>”);
client.println(“<head><meta name=\”viewport\” content=\”width=device-width, initial-scale=1\”>”);
client.println(“<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ /”>”);
client.println(“<link rel=\”icon\” href=\”data:,\”>”);
// CSS to style the on/off buttons
// Feel free to change the background-color and font-size attributes to fit your preferences
client.println(“<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}”);
client.println(“.button { background-color: #195B6A; border: none; color: white; padding: 16px 40px;”);
client.println(“text-decoration: none; font-size: 30px; margin: 2px; cursor: pointer;}”);
client.println(“.button2 {background-color: #1fd787;}</style></head>”);
You are escaping (using a back slash) double quote characters to use inside a double quoted string. Whilst this is workable it leads to difficult to read (And troubleshoot) strings. In your case on the third line you are missing the escape characters for the double quotes.
A better way to do this is to get rid of the escapes altogether (Only use escapes when absolutely necessary). Use single quotes inside a double quoted string (or use double quotes inside a single quoted string). For example, your second line could be:
client.println(“<head><meta name=’viewport’ content=’width=device-width, initial-scale=1′>”);
or
client.println(‘<head><meta name=”viewport” content=”width=device-width, initial-scale=1”>’);
So, either add the required escapes to your third line or remove them altogether using the above.
Hello Steve!
Thank you for your explonation, now I have got this to work! It looks like this :
// Display the HTML web page
client.println(“<!DOCTYPE html><html>”);
client.println(“<head><meta name=’viewport’ content=’width=device-width, initial-scale=1′>”);
client.println(“<meta http-equiv=’Content-Type’ content=text/html; charset=utf-8 /’>”);
client.println(“<link rel=\”icon\” href=\”data:,\”>”);
So the case resolved