Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re^3: Encoding/decoding for korean strings

by siva_pm (Novice)
on Jun 15, 2016 at 19:19 UTC ( #1165782=note: print w/replies, xml ) Need Help??

in reply to Re^2: Encoding/decoding for korean strings
in thread Encoding/decoding for korean strings

Below are the methods that deal with the encoding/decoding So I'm calling handleRequest($fun,$parameters) from my cgi file which calls a which initially does an eval call to handleRequest which firstly does eval call looks like this:

sub handle_req_cgi{ eval { $log->info("pjb.cgi - Started function $function , user: $user_ +name"); $msg = UI::PJB::handleRequest($function, $parameters); 1; } //Response $tx->res->code($res_code); $tx->res->headers->content_type('application/json'); $tx->res->body(encode('UTF-8',$msg)); #THIS IS THE LINE which corrupts the msg but if I print just the msg w +ithout encode then #wide character warning is thrown by Mojo $tx->rendered; }
handleRequest() # looks like this: { $jsonDecodedParameters = $J->decode($parameters); my $result = executeFunction($fun, $jsonDecodedParameters); if(ref $result eq ref {} && defined $result->{$HTTP_REQUEST_REDIRECT_U +RL_KEY}) { $jsonEncodedResult = $J->encode($result); returns this $jsonEncodedResult }

then the control inside proceeds to write the response of

Replies are listed 'Best First'.
Re^4: Encoding/decoding for korean strings
by graff (Chancellor) on Jun 15, 2016 at 21:56 UTC
    Maybe there's something I'm not understanding, but there's nothing in the first snippet that calls the "handle_pjb_cgi" function in the second snippet, and so I have no idea what the "$tx" thing is. Assuming "handle_pjb_cgi" is being passed the sort of object it should be getting, the description in the OP makes it sound like whatever file handle is being used to "print" the the "message" has not been set to use a utf8 layer.

    I gather from your other reply below that you've confirmed there is valid utf8 data stored in the database, so the problem would seem to be limited to the output process, and probably involves the discipline setting on the output file handle. But I'm just guessing here.

      the first snippet which has the sub handle_pjb_cgi has eval (if you look into it, which calls handleRequest()) tx is a transaction obj (not needed for now)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1165782]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2021-04-21 03:11 GMT
Find Nodes?
    Voting Booth?

    No recent polls found