[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Character translation problem



Rich

> If I read your note correctly, the "funny characters" (specifically,
> weird quote marks) are accepted by a CGI script from material that
> is being pasted into an HTML form by some of your users.

Correct. Maybe I was too good at being brief..

> Only the users whose desktop machines are PCs (using MW Word?) have
> this problem.  You have some code which, when run under MacPerl, is
> able to replace the characters with "normal" characters.  It fails,
> however, when run on a Unix box.

Yes.

> As your code indicates, the weird characters have their eighth (sign)
> bits set.

That one's over my head. I used Fetch to get the file off the server and
GeneralEdit Lite to examine it - that's where I came up with 0xE2, 0xE3, and
0xE4 for the offending charcters. I spent a little time with the llama and
camel, came up with a sub that worked in Macperl, then put it on the server.


>   This is perl, version 5.005_02 built for i386-freebsd
>
> handles the characters properly, as:
>
> % cat fred
> #!/usr/bin/perl
>
> {
>   $x1 = $x2 = $x3 = "\xE2";
>   printf("%x: %s\n", ord($x1), $x1);
>
>   $x2 =~ s/\xE2/\'/g;
>   printf("%x: %s\n", ord($x2), $x2);
>
>   $x3 =~ tr/[\200-\377]/[\000-\177]/;
>   printf("%x: %s\n", ord($x3), $x3);
> }
> % fred
> e2: ’
> 27: '
> 62: b
>
> What OS and Perl version are you running?

SunOS 5.6,
This is perl, version 5.004_04 built for sun4-solaris

I "bash"ed fred and got the same results as your test script - $x1 output is
what is getting mailed now, the $x2 is what I want to happen. Maybe it's not
actually 0xE2 on the server???

Steve Swantz
sneakers@nwaalpa.org

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org