{"id":34304,"date":"2014-10-15T12:49:04","date_gmt":"2014-10-15T17:49:04","guid":{"rendered":"http:\/\/webirix.com\/?p=34304"},"modified":"2014-10-15T12:49:04","modified_gmt":"2014-10-15T17:49:04","slug":"problemas-html-acentos-y-enes-charset-utf-8-iso-8859-1","status":"publish","type":"post","link":"https:\/\/webirix.com\/en\/problemas-html-acentos-y-enes-charset-utf-8-iso-8859-1\/","title":{"rendered":"Html accents and e\u00f1es problems: charset UTF-8 \/ ISO-8859-1"},"content":{"rendered":"<header>\n<h2 class=\"titleNoticia\">The coding of web pages (charset) is a recurring problem for webmasters, because:<\/h2>\n<\/header>\n<ul>\n<li>It depends on the editor in which the web was made, if we work by default in UTF-8 or ISO-8859-1. If the original file was written in ISO-8859-1 and we edit it in UTF-8, we will see the badly encoded special characters. If we save that file as is, we will be corrupting the original encoding (it will be saved wrong, with UTF-8). And vice versa.<\/li>\n<li>It depends on the Apache configuration.<\/li>\n<li>It depends on whether there is a hidden .htaccess file in the root directory that our website serves (httpdocs, public_html or similar)<\/li>\n<li>It depends on whether it is specified in the META tags of the resulting HTML.<\/li>\n<li>It depends on whether it is specified in the header of a PHP file.<\/li>\n<li>It depends on the charset chosen in the database (if a database is used to display content with a CMS, such as Joomla, Drupal, phpNuke, or a proprietary application that is dynamic).<\/li>\n<li><\/li>\n<\/ul>\n<p>In general, if accents or e\u00f1es never have to appear on our website, we are indifferent to the coding (although there may be other symbols that annoy us). Although if our website is in Spanish, the most normal thing is that we place accents and e\u00f1es. For this, the HTML standard is prepared to place all the symbols and accents that are necessary, encoding them. Thus, for accents and e\u00f1es, we should place:<br \/>\n<b><br \/>\n\u00e1 -&gt; \u00e1<br \/>\n\u00e9 -&gt; \u00e9<br \/>\n\u00ed -&gt; \u00ed<br \/>\nor -&gt; or<br \/>\n\u00fa -&gt; \u00fa<br \/>\n\u00f1 -&gt; \u00f1<br \/>\n<\/b><br \/>\nValencian-Catalan-Balearic variants for open accents:<br \/>\n<b><br \/>\n\u00e0 -&gt; \u00e0<br \/>\n\u00e8 -&gt; \u00e8<br \/>\n\u00f2 -&gt; \u00f2<br \/>\n<\/b><\/p>\n<p>In this way, we will see all characters correctly, regardless of the charset.<\/p>\n<p><b>However, it can be tedious for certain content to have to manually translate the characters ourselves.<\/b> It is in these cases where it is worth spending a little time adjusting the different settings.<\/p>\n<hr \/>\n<p><b>First<\/b>, it would be necessary to determine on our website with the META tags that our website should be served in the encoding that we choose. That is, within:<\/p>\n<p><b>&lt;meta http-equiv=&#8221;Content-Type&#8221; content=&#8221;text\/html; charset=UTF-8&#8243; \/&gt;<\/b><\/p>\n<p>O well<\/p>\n<p><b>&lt;meta http-equiv=&#8221;Content-Type&#8221; content=&#8221;text\/html; charset=ISO-8859-1&#8243; \/&gt;<\/b><\/p>\n<hr \/>\n<p>If we continue with the problem, <b>Second<\/b>, see if the server (apache) has a predefined charset by default. If so, the META tags in the html will be ignored.<br \/>\nOn a Linux server, the charset file is at:<\/p>\n<p><b>\/etc\/apache2\/conf.d\/charset<\/b><\/p>\n<p>can also be changed in the file <b>httpd.conf<\/b><\/p>\n<p>It should appear only <b>&#8220;AddDefaultCharset off&#8221;<\/b>, para que haga caso de las etiquetas META (lo ideal). Podemos poner, por ejemplo, &#8220;AddDefaultCharset UTF-8&#8221;, y as\u00ed apache siempre emitir\u00e1 las webs en UTF-8. El problema es que esto afecta a todo el servidor, y si luego tenemos alguna web que vaya a usar otra codificaci\u00f3n tendremos un problema. Por eso, lo ideal es que est\u00e9 a Off y que cada web defina c\u00f3mo quiere mostrarse.<\/p>\n<p><b>But it may be the case that we are not the server administrators and we only have a Plesk<\/b>, and we cannot access the charset file because it is outside our range of permissions. We can then ask the server administrator to set the previous parameter to Off, or else ...<\/p>\n<hr \/>\n<p><b>Alternative 1: Drop a file <b>.htaccess<\/b> in the root directory of the web<\/b><br \/>\nThe <b>.htaccess<\/b> they are configuration files that overwrite some apache configurations only for certain cases. Keep in mind that these files:<\/p>\n<ul>\n<li>They can work totally or partially, depending on the configuration of the server (security question).<\/li>\n<li>Son archivos ocultos, por lo que para verlos ten\u00e9is que tener habilitada la funci\u00f3n &#8220;ver archivos ocultos&#8221; en vuestro programa que acceda por ftp.<\/li>\n<\/ul>\n<p>This file <b>.htaccess<\/b> should have at least one such line<\/p>\n<p><b>AddDefaultCharset utf-8<\/b><\/p>\n<hr \/>\n<p><b>Alternative 2: Put a directive in php that forces it to be displayed in the desired encoding<\/b><br \/>\nEsto es, s\u00f3lo sirve si el archivo tiene extensi\u00f3n &#8220;.php&#8221;. Recordemos que el html y el php pueden convivir en el mismo fichero, con lo que si renombramos un &#8220;.html&#8221; a &#8220;.php&#8221;, el resutlado es exactamente el mismo (si tenemos instalado el php en nuestro servidor, claro est\u00e1).<br \/>\nIn the first line of the file that we want to indicate the encoding (or as soon as possible) you should place the following header:<\/p>\n<div class=\"codeblock\"><code>&lt;?php<br \/>\nheader (&#039;Content-Type: text \/ html; charset = UTF-8&#039;);<br \/>\n?&gt;<\/code><\/div>\n<hr \/>","protected":false},"excerpt":{"rendered":"<p>The coding of web pages (charset) is a recurring problem for webmasters, because: It depends on the editor in which the web was made, if we work by default in UTF-8 or ISO-8859-1. If the original file was written in ISO-8859-1 and we edit it in UTF-8, we will see the badly encoded special characters. Yes \u2026<\/p>","protected":false},"author":2,"featured_media":34305,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2011,2013],"tags":[],"class_list":["post-34304","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-actualidad","category-disenoweb"],"jetpack_featured_media_url":"https:\/\/webirix.com\/wp-content\/uploads\/2014\/10\/enies.png","_links":{"self":[{"href":"https:\/\/webirix.com\/en\/wp-json\/wp\/v2\/posts\/34304","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webirix.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webirix.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webirix.com\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/webirix.com\/en\/wp-json\/wp\/v2\/comments?post=34304"}],"version-history":[{"count":1,"href":"https:\/\/webirix.com\/en\/wp-json\/wp\/v2\/posts\/34304\/revisions"}],"predecessor-version":[{"id":34306,"href":"https:\/\/webirix.com\/en\/wp-json\/wp\/v2\/posts\/34304\/revisions\/34306"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webirix.com\/en\/wp-json\/wp\/v2\/media\/34305"}],"wp:attachment":[{"href":"https:\/\/webirix.com\/en\/wp-json\/wp\/v2\/media?parent=34304"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webirix.com\/en\/wp-json\/wp\/v2\/categories?post=34304"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webirix.com\/en\/wp-json\/wp\/v2\/tags?post=34304"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}