You are here

function pBarcode128::encode128 in Visitors 7.2

Same name and namespace in other branches
  1. 7 pChart/class/pBarcode128.class.php \pBarcode128::encode128()
2 calls to pBarcode128::encode128()
pBarcode128::draw in pChart/class/pBarcode128.class.php
pBarcode128::getSize in pChart/class/pBarcode128.class.php

File

pChart/class/pBarcode128.class.php, line 79

Class

pBarcode128

Code

function encode128($Value, $Format = "") {
  $this->Result = "11010010000";
  $this->CRC = 104;
  $TextString = "";
  for ($i = 1; $i <= strlen($Value); $i++) {
    $CharCode = ord($this
      ->mid($Value, $i, 1));
    if (isset($this->Codes[$CharCode])) {
      $this->Result = $this->Result . $this->Codes[$CharCode]["Code"];
      $this->CRC = $this->CRC + $i * $this->Codes[$CharCode]["ID"];
      $TextString = $TextString . chr($CharCode);
    }
  }
  $this->CRC = $this->CRC - floor($this->CRC / 103) * 103;
  $this->Result = $this->Result . $this->Reverse[$this->CRC]["Code"];
  $this->Result = $this->Result . "1100011101011";
  return $TextString;
}