Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

How to deal with mixed encoding.

by Anonymous Monk
on Jul 13, 2022 at 13:35 UTC ( [id://11145488]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I have the below string which seems to be having mixed encoding/decoding and needs to be decoded/encoded properly.
z�ta z�ta should be printed as zéta zéta on the browser.

Any suggestion or help would be appreciated. Thank you.

Replies are listed 'Best First'.
Re: How to deal with mixed encoding.
by Corion (Patriarch) on Jul 13, 2022 at 13:39 UTC

    So - what is the encoding in the string as you read it in? What is the encoding of the HTML page where you need to display the string?

    See Encode:

    my $zeta_zeta = <>; # read the input from somewhere my $str = decode('Latin-1', $zeta_zeta); my $html = <<'HTML'; <html> <head> <meta charset="utf-8" /> </head> <body> Hello World HTML $html .= encode('UTF-8',$str); print $html;
Re: How to deal with mixed encoding.
by cavac (Parson) on Jul 14, 2022 at 12:44 UTC

    cavac's QRH checklist for "Before dealing with character encodings (Unicode or otherwise)":

    1. Make sure Aspirin (or similar headache medicine) is available at your desk.
    2. Make sure the nearest wall is sufficiently soft (pad where required).
    3. Warn coworkers that loud cursing and profanity will be heard from your desk.
    4. Issue OSHA approved safety equipment to coworkers to protect against thrown objects.
    5. Put any irreplacable objects out of immediate reach.
    6. Get down on knees and pray to any $DEITY that would listen that your project doesn't use C libraries.
    7. Give the actual coding work to your intern.

    PerlMonks XP is useless? Not anymore: XPD - Do more with your PerlMonks XP

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-18 02:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found