Utf8 in web perl application (LAMP) – binmode, charset « Perl
Utf8 in web perl application (LAMP) – binmode, charset
Wednesday 16 December 2009 @ 6:57 am

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

After wrestling with perl encoding, we need to make sure the pages of website we create are displayed in utf8.
This means we need to have proper header in pages, for example:

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″>



</head>
<body>

and/or:

Content-Type: text/html; charset=utf-8

Second step, is to set binmode on STDOUT (if we print our dynamically generated webpages)

binmode STDOUT, “:utf8″;

to get rid of

Wide character in print at …

warnings.

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • email
  • LinkedIn
  • MySpace
  • Reddit
  • RSS
  • Slashdot
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Technorati
  • Twitter
  • Twitthis
  • Yahoo! Bookmarks
  • Yahoo! Buzz

See also:

  1. Utf8 in web perl application (LAMP) – dbi, mysql
  2. Utf8 in web perl application (LAMP)
  3. Utf8 in web perl application (LAMP) – part 2 – Encode
  4. Utf8 horror at LAMP – accept charset
  5. Perl WTFs – last in function

Tags: ,

Comments (2) - Posted in work by Lech  



 2 responses to “Utf8 in web perl application (LAMP) – binmode, charset”

  •   anon wrote:

    Not “and/or”. Definitely “and”. The correct Content-Type is a MUST. On the other hand, the meta element can be left out. – Avoid the transitional document types for new documents! As the name says, it is for transitioning up from HTML 3 or untyped HTML. When generating documents, you are completely under control. Use the strict document type.

  •   admin wrote:

    > Use the strict document type.

    And what benefit will this give to me? :)

Leave a comment