kyle has asked for the wisdom of the Perl Monks concerning the following question:
Gentlemonks,
At $work, a test suite has these three different methods of building a string sprinkled throughout it. Since the tests are for utf8 handling, I'm assuming that these are designed to produce a string with particular bytes in them without alerting Perl to their UTF-8 nature. The methods are:
"\x{aa}\x{42}\x{fe}"
( chr(hex('AA')) . chr(hex('42')) . chr(hex('FE')) )
pack( "C*", 0xaa, 0x42, 0xfe )
Is any of these methods preferable over the others? Is there any difference between them? Is there a way still better than any of them?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Building binary strings.
by pc88mxer (Vicar) on Nov 28, 2007 at 05:29 UTC | |
|
Re: Building binary strings.
by KurtSchwind (Chaplain) on Nov 28, 2007 at 14:28 UTC |