Hi.

I've noticed that when setting $r->user($value) if $value is a string
with the UTF8 flag on, calling $r->user returns the string without the
UTF8 flag on again.

In other words, this code:

use Devel::Peek;
$r->user($user);
warn Dump($user);
warn Dump($r->user);

If I pass $user = "úser"

the Dump of $user outputs

SV = PV(0x7f8a48d850b0) at 0x7f8a4afc1438
  REFCNT = 1
  FLAGS = (PADMY,POK,pPOK,UTF8)
  PV = 0x7f8a4bbf09d0 "\303\272ser"\0 [UTF8 "\x{fa}ser"]
  CUR = 5
  LEN = 16

Notice that the UTF8 flag is on.

But the dump of $r->user is:

SV = PV(0x7f8a42ba67c0) at 0x7f8a4afc17b0
  REFCNT = 1
  FLAGS = (PADTMP,POK,pPOK)
  PV = 0x7f8a4bbfbb60 "\303\272ser"\0
  CUR = 5
  LEN = 16

Notice that the UTF8 flag is off on the value returned by r->user.

I'm guessing this is normal behavior due to the fact that $r->user calls
the Apache C API directly?

I'm wondering how others have dealt with situations like this. Is there
any way to get a scalar out of $r->user with the UTF8 flag turned on iff
it was set with a value that had the UTF8 flag turned on?  I know the
following works:

$user = Encode::decode('UTF-8', $r->user)

But I really would have expected $r->user to return a value with the
UTF8 flag already on since the value that I used to set it did in fact
have the flag turned on.

FWIW, this is mod_perl 2.0.8, Apache 2.2.29

Regards,
Michael Schout

Reply via email to