mfcdb_comp3encode

Encode data in COMP-3 format


Prototype:

string mfcdb_comp3encode( string $text, int $comp3_type [, int $bytes ] )




This function encode $text given in COMP-3 according with $comp3_type options (see below). The optional argument $bytes specify how many bytes must be length the converted string.

COMP-3 DEFINES

MFC_COMP3_TYPE_C : positive values
MFC_COMP3_TYPE_D : negative values
MFC_COMP3_TYPE_F : unsigned values



RETURN: This function returns the encode data.

Example

<?php
 
$text = "20080822";
$data = mfcdb_comp3encode($text, MFC_COMP3_TYPE_F, 6);
 
echo "COMP-3, before: ".$text." - after: ".bin2hex($data)."\n";
 
$value = -9567;
$data = mfcdb_comp3encode($value, ($value >= 0)?MFC_COMP3_TYPE_C:MFC_COMP3_TYPE_D, 8);
 
echo "COMP-3, before: ".$value." - after: ".bin2hex($data)."\n";
 
?>
documentation/mfcdb_comp3encode.txt · Ultima modifica: 2008/08/22 23:11 da gchiesa