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?
In reply to Building binary strings. by kyle
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |