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

Re: [MacPerl] Character translation problem



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.

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.

As your code indicates, the weird characters have their eighth (sign)
bits set.  Not all Unix boxes handle "8-bit" characters properly, but
I would expect mishandling by Unix to strip off (zero out) these bits.
This would convert the characters as follows:

	\xE2	apostrophe			\x62	b
	\xE3	opening double quote		\x63	c
	\xE4	closing double quote		\x64	d

As this does not appear to be happening, I judge that your system is
passing the characters through to Perl unchanged.  So, you may have a
faulty Perl implementation.  FWIW, my Unixish Perl implementation

  % perl -v

  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?

-Rich
--
Rich Morin:          rdm@cfcl.com, +1 650-873-7841, http://www.ptf.com/~rdm
Prime Time Freeware: info@ptf.com, +1 408-433-9662, http://www.ptf.com
MacPerl: http://www.macperl.com,       http://www.ptf.com/ptf/products/MPPE
MkLinux: http://www.mklinux.apple.com, http://www.ptf.com/ptf/products/MKLP

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