in reply to How to pass a pointer to an array of 'unsigned char' C data type with Win32::API
my $data_ref = pack ('C*', (0x81 , 0x55, 0x00, 0xE0));
That is close to what you want. It would have worked on a slightly older version of Perl. However, p5p have decided that packing binary structures in Perl should honor Unicode (don't get me started). So you get problematic results:
$ say "0x81, 0x55, 0x00, 0xE0" 129 85 0 224 $ say "unpack 'U0C*', pack 'C*', 0x81, 0x55, 0x00, 0xE0" 194 129 85 0 195 160
You're first and last values, having their 8th bit set, got turned into UTF-8 byte sequences (2 bytes each). You can prepend "U0" to the front of the pack template to avoid such.
- tye
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to pass a pointer to an array of 'unsigned char' C data type with Win32::API ("U0")
by apeks_okad (Novice) on Jul 28, 2016 at 11:08 UTC | |
by syphilis (Archbishop) on Jul 28, 2016 at 14:04 UTC | |
by tye (Sage) on Jul 28, 2016 at 14:07 UTC | |
by apeks_okad (Novice) on Jul 28, 2016 at 15:52 UTC | |
by tye (Sage) on Jul 28, 2016 at 17:21 UTC | |
by apeks_okad (Novice) on Jul 28, 2016 at 22:54 UTC | |
|