Handling text for db? [solved]

Discussion forum for MOD Writers regarding MOD Development.
Locked
iankent
Registered User
Posts: 27
Joined: Thu Jun 25, 2009 3:28 pm

Handling text for db? [solved]

Post by iankent » Fri Nov 06, 2009 7:43 pm

In my Talk mod (see Mods in Development) I'm taking text input from the user and storing it in a table to be displayed later. Somebody on the demo site has noticed that it doesn't support cyrilic text, so I'm assuming I'm not handling the user input correctly.

I've tried looking through posting.php to try and find what I'm missing but I'm completely lost :p I've come across $message_parser which seems to do something similar to generate_text_for_storage, but I'm not sure what the difference is or why some parts of phpbb use one and other parts use the second.

My code, which works other than for utf8 support, looks like this:

Code: Select all

    $uid = $bitfield = $options = '';   
    $allow_bbcode = $config['talk_enable_bbcode'];
    $allow_urls = $config['talk_enable_magic_urls'];
    $allow_smilies = $config['talk_enable_smilies'];
    
    $notice_text = utf8_normalize_nfc($notice_text);

    generate_text_for_storage($notice_text, $uid, $bitfield, $options, $allow_bbcode, $allow_urls, $allow_smilies);
I'm sure its something obvious, or I'm missing out something majorly important, but I just can't see it. I've tried posting test characters in a forum topic and it works fine, and checked the database and text stored by my code just shows question marks instead so its definately something with the submission code.

thanks

edit:
I've just tried using message_parser and it seems to do exactly the same as generate_text_for_storage? it made no differene to the problem with utf8. This page seems to confirm what I'm currently doing, just don't get it!

update:
solved the problem. I needed to wrap utf8_normalize_nfc around request_var instead of doing it later, e.g. $notice_text = utf8_normalize_nfc(request_var('notice_text','',true));
have a different db problem now though lol

Locked

Return to “[3.0.x] MOD Writers Discussion”