Categories > TinyButStrong general >

htmlconv Problem

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Trent
Date: 2007-02-09
Time: 05:21

htmlconv Problem

I have a small function for parsing BBCode in my pm system.

function bbcode($txt)
{
    // bbcodes
    $bbcodes = array( "|\[b\](.+)\[/b\]|is",
                      "|\[u\](.+)\[/u\]|is",
                      "|\[i\](.+)\[/i\]|is"
                    );

    // html
    $replace = array( "<strong>$1</strong>",
                      "<u>$1</u>",
                      "<em>$1</em>"
                    );

    $txt = preg_replace($bbcodes, $replace, $txt);

    return nl2br($txt);

}

I parse the message and create an array before passing it to TBS.  When I load the template my message is displayed as

<strong>Hello</strong> instead of displaying the bold part of the message in bold format.  I have tried every htmlconv value that is listed in the manual and it still displays the tags instead of formatting the text for output.  Any suggestions?
By: Trent
Date: 2007-02-09
Time: 05:31

Re: htmlconv Problem

Well, I fixed it this way:

TBS->LoadTemplate('xxx.txt',false);
By: Skrol29
Date: 2007-02-09
Time: 12:05

Re: htmlconv Problem

Hi,

It depends on when this functions is applies to data, but a TBS field like [b1.message;htmlconv=no] should have make it.
By: Trent
Date: 2007-07-06
Time: 18:06

Re: htmlconv Problem

Well, I thought I had this problem solved a few months ago, but now it's coming back to haunt me.  I've created an online multiplayer game.  In this game the members can create their own Crime Family.  They have the option of choosing any name they want for their family.  No here's the problem.  It has to do with them using Special Characters. (i.e., copyright symbol, trademark symbol etc.)

For example, one Syndicate has the name ¤©®!M!Ñ@L_!ÑT3ÑT¤.  Now on my dev machine, when I load this, it displays as "¤©®!M!Ñ@L_!ÑT3ÑT¤" like it should.  On my live server it displays at "&#65533;&#65533;&#65533;!M!&#65533;@L_!&#65533;T3&#65533;T&#65533;".

I have exact copies of my live files on my dev server.  Here is my code.

$TBS->LoadTemplate('' . TEMPLATE . 'template.html');
I have even tried
$TBS->LoadTemplate('' . TEMPLATE . 'template.html',false);
and get the same results.

Code for calling data from template:
[syndicate.syndicate_name;htmlconv=no]

The user hasn't entered HTML code to create the special characters, they have just copied and pasted the symbols because I have scripts in place to block possibly harmful HTML from being entered into the database.

I guess my main question is why would I see it the way it is intended on my dev server and not on the live server?  And is there a fix for this?
By: Skrol29
Date: 2007-07-07
Time: 17:31

Re: htmlconv Problem

You should specify the chartset of your HTML page as an argument of the LoadTemplate() function.

If you HTML is charset UTF8, then you should code
$TBS->LoadTemplate('template.html','UTF-8');

If it doesn't work, can you specify the charset of the table you are using to store data, and the type of the column ?
By: Trent
Date: 2007-07-07
Time: 23:05

Re: htmlconv Problem

Well, I've made changes to every .html template page in my site and got it working.  The problem was that the user had just copied the completed symbols, not entered the actual html code.  Once I made some changes to the template and had them update their information, every runs smoothly.

Thanks again for your help.