On Tue, 19 Nov 2002 at 11:30:17 +0200, Vladi Belperchinov-Shabanski wrote:
> 
> hi!
> 
> I hope I understand the problem correctly, i.e. `how to escape'?
> 
> In this case I always prefer:
> 
> our %ESCMAP     = ();
> for ( 0 .. 255 ) { $ESCMAP{ chr( $_ ) } = sprintf("%%%02X", $_); }

That's not enough fun:

our %ESCMAP = map { chr($_) => sprintf "%%%02X",$_ } 0..255;

:-)

> I did few benchmarks. The results were:
> (for 1_000_000 iterations over ~20 char string)

Hmm.. this will depend heavily on the number of escapees in the string.
If you're expecting hardly any, then the best algorithm may be different
dealing with running text in non-Latin script, where every char will match.

Every now and then, I get this sneaking feeling that I ought to write a
generalised "pack" that can do this sort of thing. But usually the
feeling passes.

Ian

Reply via email to