perl-unicode

Re: Unicode aware module

1999-04-22 11:27:08
At 10:39 AM 4/22/99 , Graham Barr wrote:
My thought on how to do this now is that you could do

sub abc_ascii {
 no utf8;
 # code here
}

sub abc_utf8 {
 use utf8;
 # code here
}

sub abc {
 goto $caller_is_utf8 ? &abc_utf8 : &abc_ascii;
}

but that is rather ugly. Maybe we could have a pragma that states we want
to inherit characterness from our caller.

sub abc {
 use caller 'character';
 # code here
}

which would then select the right ops at runtime. Of course this will
probably be slower.

I don't think that is necessary, I think the 'right' thing happens already. 

sub abc {
# we are in the mode of who called us;
# code here
}

        {
                use utf8;
                abc();          # abc() will be run with utf8==TRUE
        }
        {
                no utf8;
                abc();          # abc() will be run with utf8==FALSE
        }

So if you are dealing with characters, there are no problems, you will be
in the mode of the caller.

The only problem is if you want to be in byte mode because you are treating
strings as binary data and using character operators, then you will want to
explicitly set the mode to be a byte mode with somethinge linke C<use byte>

-- Dick

<Prev in Thread] Current Thread [Next in Thread>