Special characters "nightmare", easy fix

Yes, this one I just had to share, even if the problem and solution only matters to a very few. Or maybe only matter to me. If nothing else then I at least know where to look or search next time I stumble into a similar issue!

The problem and problem scenario

might be related to HTML pages, PHP or other applications, Content Management designs, that output some form of HTML. And particularly in situations were special characters comes into play. Like it does if you're building or publishing a site in a language requiring special characters. Now the CMS or application  language settings should normally work correctly, but if the design mechanism isn't loaded as it should the viewer might end up (temporarily) looking at a PHP document without all your design specifics.

Now, the above should not be a problem UNLESS you have a very advanced design that uses specific script mechanisms to load design for given sections. Which is not entirely unlikely if you're one of those who fancy for instance advanced one-page solutions. With complex behind-the-scene designs, views, panels or sections. Some of these approaches uses particular scripts to load section design, the loading mechanism might be initialized as a part of the url or link/string. like /#scriptname=/section/loadcontent/full/DocumentID.

In the above URL #scriptname is the mechanism that loads the design and the follow parts of the path points at what is to be loaded. 

Ah yes... this might be worth to mention too

When search engines like Google, Bing or others indexes content of a page, a document ID, they strip away mechanisms or statements in the address meant to trigger the script. And indexes the direct link to the document itself. A reloading mechanism will be required to secure that users are re-directed to the document but rendered with correct design. This is not as straight forward as it seems (believe me). Another less delicate method can be to have a link somewhere in the page template that, when clicked, reloads the design.

Special Characters - solution

The above is all well but what happens, or can happen in the above scenario, is that rendering of special characters might also get corrupted. Even if your language settings are ok, and your CMS is correctly set up. Fortunately, there exists several overrides, some of these might not work everyone but one certainly will work in most cases.

  1. Go to the root directory of your web server
  2. Find the file called .htaccess
  3. Open/edit and add the following statement: AddDefaultCharset UTF-8 
    ​​​​Can be added in the beginning of the .htaccess file
  4. Save & Close

This should ensure that ANYTHING accessed on your webserver, webhotel or other, html, php etc .... always will be using UTF-8 standard character set,  and special characters displayed correctly.