[NEWBIE QUESTION] - UTF8 language settings

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dymo310
Forum Newbie
Posts: 2
Joined: Sat Sep 27, 2008 6:14 am

[NEWBIE QUESTION] - UTF8 language settings

Post by dymo310 »

hi

i have translated an ENGLISH language file to NORWEGIAN. the result of this is that the norwegian special characters wont show properly (ÆØÅæøå).

the file is saved with UTF-8 encoding using Rapid PHP Editor, in addition i have tried to insert the following into the page, inside the <?php :

mb_internal_encoding("UTF-8");

this does not help at all. any suggestion that might lead to a solution would be (highly) appriciated.


thx
dymo310
Forum Newbie
Posts: 2
Joined: Sat Sep 27, 2008 6:14 am

Re: [NEWBIE QUESTION] - UTF8 language settings

Post by dymo310 »

:?:

all this brain and no suggestions?

..
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: [NEWBIE QUESTION] - UTF8 language settings

Post by papa »

I did a function with preg_replace for Micro$oft Word and swedish letters...

Code: Select all

    function display($text) {
        //patterns to replace
        $patterns = array("/´/", "/&/", "/É/", "/é/", "/’/", "/“/", "/”/", "/Å/", "/å/", "/Ä/", "/ä/", "/Ö/", "/ö/", 
        //linkto
        "/linkto:([^http].{1,})<([a-z0-9._-\s&]+)>/i",
        //external linkto 
        "/linkto:(http:\/\/[a-zA-Z0-9._-]+)<([a-zA-Z0-9._-\s&]+)>/",
        //linkto no desc
        "/linkto:([^http][a-zA-Z0-9._-\s&]+)/i",
        //external linkto no desc
        "/linkto:(http:\/\/[a-zA-Z0-9._-]+)/",
        //mailto
        "/mailto:([a-z0-9._-]+@[a-z0-9-]+\.[a-z.]{2,5})<([a-z0-9._-\s@]+)>/i",
        //Img
        "/img:([a-z0-9._-]+)/i");
        
        //replacements
        $replacements = array("'", "&", "&Eacute;", "&eacute;", "&rsquo;", "&ldquo;", "&rdquo;", "&Aring;", "&aring;", "&Auml;", "&auml;", "&Ouml;", "&ouml;", 
        "<a href=\"$1\">$2</a>", 
        "<img src=\"./Common/gul_pil.gif\" alt=\"gul_pil\" /><a href=\"$1\" target=\"self\">$2</a>",
        "<a href=\"$1\">$1</a>",
        "<a href=\"$1\" target=\"self\">$1</a>", 
        "<img src=\"./Common/mail.gif\" alt=\"mail\" /> <a href=\"mailto:$1\">$2</a>",
        "image man");
 
        $text = preg_replace($patterns, $replacements, $text);
        return $text;
    }
The other patterns are linking url or mailto in content text.

Hope it helps. Validates at least. :)

Norwegian chars should be here: http://webdesign.about.com/library/bl_htmlcodes.htm
Post Reply