Jump to content

latin and space problem at bbcode


UnknownPlayer

Recommended Posts

I have problem, when i put these characters: čšđć in my var to echo it works, but  when i use these characters in bbcode($Input) function it does not show that characters, it shows me Ä� or something like that.

Or when i put more spaces in var(var goes through bbcode($input) function) it show me Ä this character.

How can i fix this problem?

 

This is bbcode function:

    function bbcode($input){
        $input = strip_tags($input);
        $input = htmlentities($input);
        
        $search = array(
                    '/\[b\](.*?)\[\/b\]/is',
                    '/\[i\](.*?)\[\/i\]/is',
                    '/\[u\](.*?)\[\/u\]/is',
                    '/\[code\](.*?)\[\/code\]/is',
                    '/\[quote\](.*?)\[\/quote\]/is',
                    '/\[img\](.*?)\[\/img\]/is',
                    '/\[url=http://(.*?)\](.*?)\[\/url\]/is',
                    '/\[color=(.*?)\](.*?)\[\/color\]/is',
                    '/\[yt\]http:\/\/(?:www\.)?youtube\.com\/watch\?v=(.*?)\[\/yt\]/is',
        );
        
        $replace = array(
                    '<b>$1</b>',
                    '<i>$1</i>',
                    '<u>$1</u>',
                    '<code>$1</code>',
                    '<blockquote>$1</blockquote>',
                    '<img src="$1" style="border:0">',
                    '<a href="$1">$2</a>',
                    '<font style="color:$1">$2</font>',
                    '<object width="580" height="360">
                    <param name="movie" value="http://www.youtube.com/v/$1?fs=1&hl=sr_RS&border=1" />
                    <param name="allowFullScreen" value="true" />
                    <param name="allowscriptaccess" value="always" /><embed type="application/x-shockwave-flash" width="580" height="360" src="http://www.youtube.com/v/$1?fs=1&hl=sr_RS&border=1" allowscriptaccess="always" allowfullscreen="true"></embed>
                    </object>',
        );
        
        return nl2br(preg_replace($search,$replace,$input));
    }

 

I think that problem is becouse of tihis:

        $input = strip_tags($input);
        $input = htmlentities($input);

Help please.

Link to comment
Share on other sites

I use function like this now:

    function bbcode($input){
        $input = strip_tags($input);
        
        $search = array(
                    '/\[b\](.*?)\[\/b\]/is',
                    '/\[i\](.*?)\[\/i\]/is',
                    '/\[u\](.*?)\[\/u\]/is',
                    '/\[code\](.*?)\[\/code\]/is',
                    '/\[quote\](.*?)\[\/quote\]/is',
                    '/\[img\](.*?)\[\/img\]/is',
                    '/\[url=http://(.*?)\](.*?)\[\/url\]/is',
                    '/\[color=(.*?)\](.*?)\[\/color\]/is',
                    '/\[yt\]http:\/\/(?:www\.)?youtube\.com\/watch\?v=(.*?)\[\/yt\]/is',
        );
        
        $replace = array(
                    '<b>$1</b>',
                    '<i>$1</i>',
                    '<u>$1</u>',
                    '<code>$1</code>',
                    '<blockquote>$1</blockquote>',
                    '<img src="$1" style="border:0">',
                    '<a href="$1">$2</a>',
                    '<font style="color:$1">$2</font>',
                    '<object width="580" height="360">
                    <param name="movie" value="http://www.youtube.com/v/$1?fs=1&hl=sr_RS&border=1" />
                    <param name="allowFullScreen" value="true" />
                    <param name="allowscriptaccess" value="always" /><embed type="application/x-shockwave-flash" width="580" height="360" src="http://www.youtube.com/v/$1?fs=1&hl=sr_RS&border=1" allowscriptaccess="always" allowfullscreen="true"></embed>
                    </object>',
        );
        
        return nl2br(preg_replace($search,$replace,$input));
    }

That is wrong, or no ? :(

How can i use this function on right way ? :/

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.