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
https://forums.phpfreaks.com/topic/214834-latin-and-space-problem-at-bbcode/
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 ? :/

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.