Forums

Unicode/Western character encoding (2 posts)

  1. madsphi
    Member
    Posted 5 years ago #

    I have a site in Danish, http://www.kortx.dk

    I have written some PHP code in single.php, so content can be generated from a database. The headers of the generated posts are written manually in WP Edit Post, while all the text is generated by my code.
    http://www.kortx.dk/kort-over-danmark/

    My problem is the posts with headers and text containing the special Danish characters. The headers in those posts looks fine in Firefox with Unicode encoding (default), while all the text only looks fine with Western encoding.
    http://www.kortx.dk/kort-over-oestrig/

    Any idea how I can fix that?

    Thank you, Mads

  2. madsphi
    Member
    Posted 5 years ago #

    Still no idea why it do the above, but now I have at least found a solution.

    All the relevant texts from the database are send through the method below and then everything looks fine.

    function ConvertDanishCharacters($string)
    {
    	 $string = str_replace("æ", "&#230", $string);
    	 $string = str_replace("Æ", "&#198", $string);
    	 $string = str_replace("ø", "&#248", $string);
    	 $string = str_replace("Ø", "&#216", $string);
    	 $string = str_replace("å", "&#229", $string);
    	 $string = str_replace("Å", "&#197", $string); 
    
    	return $string;
    }

Topic Closed

This topic has been closed to new replies.

About this Topic