Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Do you have some method other than Perl for inspecting the contents of the database? It's important to know for sure that the database contains "correct" data in the first place.

If that's true, the next thing is to make sure what character encoding is being used by the database server to store (or return) the data.

If the database stores/returns data in UTF-8 encoding, the next thing is to do just one of the following (whichever one is easiest or makes the most sense):

1. Figure out how to configure your perl DBI connection to the database, so that perl will know that it's getting UTF-8 data in response to queries. OR

2. Connect using the "easiest" (default) method, and use Encode; process each string you get from a query like this:

my $usable_string = decode( 'utf8', $string_from_database );
The latter approach would also work if you find out that the database server returns strings using some other encoding (e.g. "gb2312" or whatever) - just use that other encoding in place of "utf8" in the decode() call, and that will turn the database string into perl-internal (usable) utf8.

If you have trouble, you'll need to show us (1) an example of data you expect to get back (because you've seen this data using some other tool to query the database), (2) the perl code you used to try getting the string, and (3) what you actually got from your perl script.

As indicated in a previous reply above, it may also be important to ensure that you are using a terminal or other display method that you are sure is able to "do the right thing" with the text in question.


In reply to Re: Perl DBI can't display Chinese text? by graff
in thread Perl DBI can't display Chinese text? by Thai Heng

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (6)
As of 2024-03-28 22:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found