Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^5: How to avoid decoding string to utf-8.

by haj (Vicar)
on Oct 12, 2020 at 09:54 UTC ( [id://11122741]=note: print w/replies, xml ) Need Help??


in reply to Re^4: How to avoid decoding string to utf-8.
in thread How to avoid decoding string to utf-8.

I'm sorry, but it is unclear to me what "seeing this result on web application" actually means. Where do the data come from? Is your Perl code running as part of the web application, or did you write a web client and are trying to decode a response? How did you build $teststr, and how is it different from the example in my code? Where did you insert the code we suggested?

In particular, my code example does not return anything, so I can't connect to "returning the same result". Without context, I can't offer any more.

  • Comment on Re^5: How to avoid decoding string to utf-8.

Replies are listed 'Best First'.
Re^6: How to avoid decoding string to utf-8.
by Anonymous Monk on Oct 12, 2020 at 11:27 UTC
    Hi Haj, Thank you for the reply.

    1.Data comes from the Database, as it is same as you look on the web application.
    2. Yes, Perl code is running as part of web application.
    3. TestStr is basically coming from database which got inserted while submit Form from the application itself, but at the time of showing this string on the web application this issue occurs.

    as I said earlier, I have strings with mixed encodings, which means that one string is differently encoded with another due to upgrade of application from legacy application.

    Thank you.

      So you appear to have strings with different encodings in your database. That's really bad, because you won't get correct results from database queries until you get this fixed.

      I have difficulties to understand why the regular expression does not change the result unless you are several levels of encoding away from the truth. This can happen if during the upgrade someone tried to fiddle with encoding until the result "looks right" in the browser - but what you actually have now is just a cancellation of errors. Encoding matters in the transfer from the browser form to the web application, when writing from the web application to the database, and in the opposite direction when reading from the database and when sending the data to your browser. Please tell us how you control encoding in these four places.

      For obtaining some data for debugging, please print the data - good and bad - like this (also suggested by ikegami earlier in this thread):

      printf("%vX", $testStr);

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-25 09:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found