in reply to Russian Language read from mysql into perl script problem

and submit that, when I check the database it has this:

[ I'm going with the assumption that the problem is that the database actually has stuff in the &# notation. If PerlMonks did that, let me know. ]

It's not Perl that did it. It's the browser that encoded the characters that way because it was asked to encode characters that didn't exist in the encoding it was directed to use (e.g. characters outside of iso-8859-1 when the encoding of the form's page is iso-8859-1).

I made sure my headers in the browser that perl prints have the correct encoding

If the problem is as I described, you shouldn't have the problem if the page containing the form is encoded using UTF-8.

What content type do you specify in the actual HTTP header. You've only shown the the content type you tell the browser the header should have contained.

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

Unrelated to your question: You claim your content is HTML, but that "/" at the end is illegal HTML.
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
should be
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

Replies are listed 'Best First'.
Re^2: Russian Language read from mysql into perl script problem
by powerhouse (Friar) on Feb 23, 2010 at 21:27 UTC
    Ok, I changed it to:
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    then I went into the table and had it save the content in the russian language again, now when I went to the editor and viewed it again I see this:

    Current Content(on Page):
    ???????? - ???????????????? ????
    Content in Database(in MySql)As displayed here:
    Принимаю - зарегистрировать меня

    So it still does not seem to work.
    when I pulls the russian language directly out of the datbase for some reason it just shows the ?? on the page, when I view the source I also only see the ?? on the page, so it seems to be Perl, because the source code should be what is in the table right?

    I don't know... still confused by it.

    Thank you and I do appreciate any further advice.

    thx,
    Richard

      Ok, my assumption was wrong. My question is still relevant, so I'll ask it again, with some additional questions.

      • What content type do you specify in the actual HTTP header. You've only shown the the content type you tell the browser the header should have contained.

      • How do you encode the HTML you send to the browser?

      • What do you get if you Dump the value you get from the database? (Output sent to STDERR, so you'll probably have to check your logs.)

        Ok, I am going to install Devel::Peek and do a dump to see... I'll create a new reply with that when I'm done. To answer the other question:

        What content type do you specify in the actual HTTP header. You've only shown the the content type you tell the browser the header should have contained.
        Response: Here is the html output perl is printing:
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-U +S"> <head> <title>Richard's Back Office Manager</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-language" content="RU"> <meta name="audience" content="All" />
        That is the first part of the header.

        How do you encode the HTML you send to the browser?

        Response: I don't really 'encode' it, here is how I write that page that has the problem displaying the database content:

        #Get the content of the language tag to be edited from the dat +abase table... my $sth = $dbh->prepare(qq{select * from `$_tableName` where ` +lngId` = ?}); $sth->execute($in{lngId}); my $_tr = $sth->fetchrow_hashref(); $sth->finish(); # Got it... Check if this langauge is NOT the english version +if not then get the english version of the same tag to show the curre +nt content... if($_tableName ne "en_lang") { $sth = $dbh->prepare(qq{select * from `en_lang` where `lng +Id` = ?}); $sth->execute($in{lngId}); my $_enLang = $sth->fetchrow_hashref(); $sth->finish(); } # Build the web form $_page_content contains the whole page co +ntent which will then print in the template of the design at the end +of the programming... $_page_content .= start_form(-name=>"edit_form", -action=>url( +), -method=>"POST") . hidden(-name=>"pg") . hidden(-name=>"do") . hidden(-name=>"view", -value=>"saveTag", -override=>1) . hidden(-name=>"lngId") . hidden(-name=>"r") . hidden(-name=>"q") . hidden(-name=>"p") . hidden(-name=>"timel", -value=>time(), -override=>1) . $hidden_inc_sess_id . qq~ <table border="0" cellpadding="2" cellspacing="2" align="cente +r" width="650"> <tr> <td class="td_header_green" colspan="2"> Modify a Language Tag </td> </tr> <tr> <td class="label_cell"> Language: </td> <td class="non_label_cell"> $_languagenames{$_tableName} </td> </tr> <tr> <td class="label_cell"> Last Modified: </td> <td class="non_label_cell"> ~ . buildDate($_tr->{d},"common_layout_wt") . qq~ </td> </tr> <tr> <td class="label_cell"> Tag: </td> <td class="non_label_cell"> $_tr->{tag} </td> </tr> <tr> <td class="label_cell_center" colspan="2"> Current Content: </td> </tr> <tr> <td class="non_label_cell_center" colspan="2"> $_tr->{value} <!-- This displays the Content from +the database... --> </td> </tr> <tr> <td class="label_cell_center" colspan="2"> New Content: </td> </tr> <tr> <td class="non_label_cell_center" colspan="2"> ~ . textarea(-name=>"tagvalue", -default=>$_tr->{v +alue}, -onfocus=>"this.select()", -cols=>85, -rows=>10, -class=>"form +field") . qq~ </td> </tr> ~; # again check if this tag is not the english version if no +t, then show the english version now so they know what they should be + translating... if($_tableName ne "en_lang") { $_page_content .= qq~ <tr> <td class="label_cell" colspan="2"> English Version Content: </td> </tr> <tr> <td class="non_label_cell_center" colspan="2"> $_enLang->{value} </td> </tr> <tr> <td class="label_cell"> English Version Last Modified: </td> <td class="non_label_cell"> ~ . buildDate($_enLang->{d},"common_layout_wt") . +qq~ </td> </tr> ~; } # Done checking english version or not... complete the for +m. $_page_content .= qq~ <tr> <td class="non_label_cell_center" colspan="2"> ~ . submit(-name=>"choice", -value=>"Save Changes" +, -class=>"submit") . qq~ </td> </tr> </table> ~ . end_form() . br() x 2; # done building the web form and pa +ge...

        Ok, I will now go install the dump system to get the dump. I'll have to read the doucmentation to figure our where the dump will go, not sure since this is from a page not in the script. Guess I could make a script just of this page should I need to.

        Thanks again!!

        Will update asap.

        thx,
        Richard
        Ok, I got the dump now, sorry for the delay, hope you did not go away and come back to tell me the correct way or point me in that way...

        bash:# perl index.cgi pg=MyBackOffice do=language_tag_editor view=edit +Tag lngId=151 shell=1 SV = PV(0x76506e8) at 0x6691000 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x7dabbf0 "<form method=\"post\" action=\"http://localhost\" en +ctype=\"multipart/form-data\" name=\"edit_form\">\n<input type=\"hidd +en\" name=\"pg\" value=\"MyBackOffice\" /><input type=\"hidden\" nam +e=\"do\" value=\"language_tag_editor\" /><input type=\"hidden\" name +=\"view\" value=\"saveTag\" /><input type=\"hidden\" name=\"lngId\" +value=\"151\" /><input type=\"hidden\" name=\"r\" value=\"\" /><inp +ut type=\"hidden\" name=\"q\" value=\"\" /><input type=\"hidden\" na +me=\"p\" value=\"\" /><input type=\"hidden\" name=\"timel\" value=\" +1267175109\" />\n\t\t<table border=\"0\" cellpadding=\"2\" cellspaci +ng=\"2\" align=\"center\" width=\"650\">\n\t\t\t<tr>\n\t\t\t\t<td cla +ss=\"td_header_green\" colspan=\"2\">\n\t\t\t\t\tModify a Language Ta +g\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td class=\"label_ +cell\">\n\t\t\t\t\tLanguage:\n\t\t\t\t</td>\n\t\t\t\t<td class=\"non_ +label_cell\">\n\t\t\t\t\tRussian\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t< +tr>\n\t\t\t\t<td class=\"label_cell\">\n\t\t\t\t\tLast Modified:\n\t\ +t\t\t</td>\n\t\t\t\t<td class=\"non_label_cell\">\n\t\t\t\t\t02/23/10 + 01:24 PM\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td class= +\"label_cell\">\n\t\t\t\t\tTag:\n\t\t\t\t</td>\n\t\t\t\t<td class=\"n +on_label_cell\">\n\t\t\t\t\tJoinPage_Final_RegisterButton\n\t\t\t\t</ +td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td class=\"label_cell_center\" + colspan=\"2\">\n\t\t\t\t\tCurrent Content:\n\t\t\t\t</td>\n\t\t\t</t +r>\n\t\t\t<tr>\n\t\t\t\t<td class=\"non_label_cell_center\" colspan=\ +"2\">\n\t\t\t\t\t???????? - ???????????????? ????\n\t\t\t\t</td>\n\t\ +t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td class=\"label_cell_center\" colspan +=\"2\">\n\t\t\t\t\tNew Content:\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<t +r>\n\t\t\t\t<td class=\"non_label_cell_center\" colspan=\"2\">\n\t\t\ +t\t\t<textarea name=\"tagvalue\" rows=\"10\" cols=\"85\" onfocus=\"t +his.select()\" class=\"formfield\">???????? - ???????????????? ????</ +textarea>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t\n\t\t\t<tr>\n\t\t\t\t<t +d class=\"label_cell\" colspan=\"2\">\n\t\t\t\t\tEnglish Version Cont +ent:\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td class=\"non +_label_cell_center\" colspan=\"2\">\n\t\t\t\t\tI agree - Register Me\ +n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td class=\"label_ce +ll\">\n\t\t\t\t\tEnglish Version Last Modified:\n\t\t\t\t</td>\n\t\t\ +t\t<td class=\"non_label_cell\">\n\t\t\t\t\t02/22/10 09:36 PM\n\t\t\t +\t</td>\n\t\t\t</tr>\n\t\t\t\t\n\t\t\t<tr>\n\t\t\t\t<td class=\"non_l +abel_cell_center\" colspan=\"2\">\n\t\t\t\t\t<input type=\"submit\" n +ame=\"choice\" value=\"Preview Changes\" class=\"submit\" />\n\t\t\t\ +t</td>\n\t\t\t</tr>\n\t\t</table>\n\t\t</form><br /><br />"\0 CUR = 2240 LEN = 2248
        See even in their they are all ??? marks...

        That is what makes me think Perl does not like the cryllic text or something.

        BTW, I tried doing this:
        use open ':utf8'; use utf8;
        that did not do it. Still see just ???? marks in the out put on the page.

        Any ideas now?

        thx,
        Richard