Return-Path: X-Original-To: apmail-perl-asp-archive@www.apache.org Delivered-To: apmail-perl-asp-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7F8E1C510 for ; Tue, 5 Jun 2012 09:03:33 +0000 (UTC) Received: (qmail 50062 invoked by uid 500); 5 Jun 2012 09:03:33 -0000 Delivered-To: apmail-perl-asp-archive@perl.apache.org Received: (qmail 49226 invoked by uid 500); 5 Jun 2012 09:03:28 -0000 Mailing-List: contact asp-help@perl.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list asp@perl.apache.org Received: (qmail 49099 invoked by uid 99); 5 Jun 2012 09:03:27 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Jun 2012 09:03:27 +0000 X-ASF-Spam-Status: No, hits=1.6 required=5.0 tests=RCVD_IN_BRBL_LASTEXT,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of arnon@back2front.ca designates 208.116.26.69 as permitted sender) Received: from [208.116.26.69] (HELO hosting1.back2front.ca) (208.116.26.69) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Jun 2012 09:03:19 +0000 Received: from hosting1.back2front.ca (localhost [127.0.0.1]) by hosting1.back2front.ca (Postfix) with ESMTP id EDDB21D20007 for ; Tue, 5 Jun 2012 05:02:52 -0400 (EDT) Received: from [192.168.0.10] (unknown [99.237.180.11]) by hosting1.back2front.ca (Postfix) with ESMTPA for ; Tue, 5 Jun 2012 05:02:52 -0400 (EDT) Message-ID: <4FCDCB3B.2090406@back2front.ca> Date: Tue, 05 Jun 2012 05:02:51 -0400 From: Arnon Weinberg Organization: Back2Front User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.9) Gecko/20100430 Fedora/3.0.4-2.fc11 Thunderbird/3.0.4 MIME-Version: 1.0 To: asp@perl.apache.org Subject: Output character encoding Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit How can I set the output character encoding of Apache::ASP output? Regular perl/CGI output defaults to ISO-8859-1 encoding, and may be easily modified using the use open prama or binmode() function. Here is my test script: # Latin-1.cgi: ############## #use open ( ":utf8", ":std" ); #binmode ( STDOUT, ":encoding(ISO-8859-1)" ); use CGI; print CGI::header(); use Encode; print Encode::decode('ISO-8859-1',"\xE2"), Encode::decode('UTF-8',Encode::encode('UTF-8',"\xE2")), "\x{00E2}", chr(0x00E2); ############################# >perl Latin-1.cgi Content-Type: text/html; charset=ISO-8859-1 ���� >perl Latin-1.cgi | tail -1 | hexdump 0000000 e2e2 e2e2 0000004 This script correctly produces ISO-8859-1 encoded output. However, Apache::ASP appears to default to some strange mix of ISO-8859-1 and UTF-8 that I can't make sense of. Additionally, the use open pragma and binmode() function appear to have no effect: # Latin-1.rasp: ############# <% #use open ( ":utf8", ":std" ); #binmode ( STDOUT, ":encoding(ISO-8859-1)" ); $::Response->{Charset} = "ISO-8859-1"; use Encode; print Encode::decode('ISO-8859-1',"\xE2"), Encode::decode('UTF-8',Encode::encode('UTF-8',"\xE2")), "\x{00E2}", chr(0x00E2); %> ############################# >asp-perl Latin-1.rasp Content-Type: text/html; charset=ISO-8859-1 Content-Length: 6 Cache-Control: private ââ�� >asp-perl Latin-1.rasp | tail -1 | hexdump 0000000 a2c3 a2c3 e2e2 0000006 For some reason, the first 2 test characters are UTF-8 encoded, and the last 2 are ISO-8859-1 encoded. How can I get the same results as the CGI script above? -- ------------------------------------------------------------------------------- Arnon Weinberg www.back2front.ca --------------------------------------------------------------------- To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org For additional commands, e-mail: asp-help@perl.apache.org