NAME

GDPR::IAB::TCFv2::BitUtils - TCF v2.3 bit-level decoding utilities

SYNOPSIS use GDPR::IAB::TCFv2::BitUtils qw<is_set get_uint16>;

my $data = '...'; # raw binary data

my $max_vendor_id_consent = get_uint16($data, 213);
my $is_service_specific   = is_set( $data, 138 );

get_uint2

Receive two parameters: data and bit offset.

Will fetch 2 bits from data since bit offset and convert it to an unsigned int.

my $value = get_uint2( $data, $offset );

get_uint3

Receive two parameters: data and bit offset.

Will fetch 3 bits from data since bit offset and convert it to an unsigned int.

my $segment_type = get_uint3( $data, 0 );

get_uint6

Receive two parameters: data and bit offset.

Will fetch 6 bits from data since bit offset and convert it to an unsigned int.

my $version = get_uint6( $data, 0 );

get_char6_pair

Receives the data and bit offset.

Reads two consecutive 6-bit values starting at $offset, increments each by the ASCII value of the letter A, and returns the resulting two-letter string. Used to decode the consent_language and publisher_country_code fields of the TCF v2 core string.

my $consent_language = get_char6_pair($data, 108); # returns two letter country encoded as ISO_639-1

get_uint12

Receives the data and bit offset.

Will fetch 12 bits from data since bit offset and convert it to an unsigned int (short).

my $cmp_id = get_uint12( $data, 78 );

get_uint16

Receives the data and bit offset.

Will fetch 16 bits from data since bit offset and convert it to an unsigned int (short).

my $max_vendor_id_consent = get_uint16( $data, 213 );

get_uint36

Receives the data and bit offset.

Will fetch 36 bits from data since bit offset and convert it to an unsigned int (long).

my $deciseconds = get_uint36( $data, 6 );
my $created = $deciseconds/10;