Sample code for 30+ languages & platforms
Perl

Appending Strings to BinData

Demonstrates appending strings to a BinData..

Chilkat Perl Downloads

Chilkat2 Perl
use strict;
use warnings;
use Chilkat2;

my $binData1 = Chilkat2::BinData->new;

# Append a string using a 1-byte per char encoding
$binData1->AppendString('This is a test', 'windows-1252');
print $binData1->GetEncoded('hex'), "\n";
# The bytes contained within the binData1 (in hex) are: 54,68,69,73,20,69, ...

my $binData2 = Chilkat2::BinData->new;

# Append a string using a 2-byte per char encoding
$binData2->AppendString('This is a test', 'utf-16');
print $binData2->GetEncoded('hex'), "\n";
# The bytes contained within the binData2 (in hex) are: 54,00,68,00,69,00,73,00,20,00,69,00, ...