---
name: "Barcode::DataMatrix::Engine"
section: "3pm"
platform: "linux"
package: "libbarcode-datamatrix-perl"
version: "0.10-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Barcode::DataMatrix::Engine"
---

# Barcode::DataMatrix::Engine(3pm)

The engine which generates the data matrix bitmap.

## NAME

Barcode::DataMatrix::Engine - The engine which generates the data matrix bitmap.

### DEBUG

Turn on/off general debugging information.

### E\_ASCII

Represent the ASCII encoding type.

### E\_C40

Represent the C40 encoding type.  (upper case alphanumeric)

### E\_TEXT

Represent the TEXT encoding type.  (lower case alphanumeric)

### E\_BASE256

Represent the BASE256 encoding type.

### E\_NONE

Represent the when there is no encoding type.

### E\_AUTO

Represent the when the encoding type is automatically set.

### Types

Return a list of encoding types.

### stringToType (type\_name)

Return the integer representing the type from the type name.

### typeToString (type\_integer)

Return the type name from the integer representing the type.

### stringToFormat (format\_string)

Convert a "width x height" format string into an internal format specification.

### setType (type\_name)

Set the encoding type from the given type name.

### new

Construct a `"Barcode::DataMatrix::Engine"` object.

### init

Initialize some of the basic `"Barcode::DataMatrix::Engine"` data.

### ProcessTilde

Handle special or control characters, which are prefixed by a tilde `"~"` when encoding.

### CalcReed (ai, err)

Return the message as a Reed-Solomon encoded array.

### A253 (i, j)

Return padding codewords via the 253-state algorithm.

For more information see \<http://grandzebu.net/informatique/codbar-en/datamatrix.htm\>.

The relevant text for this algorithm is reproduced here.

If the symbol is not full, pad `"CW"`s are required. After the last data `"CW"`, the 254 `"CW"` indicates the end of the datas or the return to ASCII method. First padding `"CW"` is 129 and next padding `"CW"`s are computed with the 253-state algorithm.

*The 253-state algorithm*

Let `"P"` be the number of data `"CW"`s from the beginning of the data, `"R"` a pseudo random number and `"CW"` the required pad `"CW"`.

```
    R = ((149 * P) MOD 253) + 1
    CW = (129 + R) MOD 254
```

### CreateBitmap

Generate and return the bitmap representing the message.

### ecc (format, ai)

Return the ECC200 (DataMatrix) array, formatted for the appropriate matrix size.

### isIDigit (character\_code)

Return true if the character code represents a digit.

### isILower (character\_code)

Return true if the character code represents a lower case letter.

### isIUpper (character\_code)

Return true if the character code represents an upper case letter.

### DetectEncoding

Detect the encoding type.

### EncodeASCII (i, ai, ai1, as)

Encode the message as ASCII.

### SelectEncoding (j, ai, i)

Select a new encoding type for the message.

### EncodeC40TEXT (i, ai, ai1, ai2, flag, flag1, flag2)

Encode the message as C40/TEXT.

### state255 (V, P)

The 255-state algorithm.  Used when encoding strings with the BASE256 type.

This information originally from \<http://grandzebu.net/informatique/codbar-en/datamatrix.htm\>.

Let `"P"` the number of data `"CW"`s from the beginning of datas (`"CW"` = code word).  Let `"R"` be a pseudo random number, `"V"` the base 256 `"CW"` value and `"CW"` the required `"CW"`.

```
    R = ((149 * P) MOD 255) + 1
    CW = (V + R) MOD 256
```

### hexary (src)

Return a string representation of the input hexadecimal number.

### EncodeBASE256 (i, hint, src, stat, res, flag)

Encode the message as BASE256.

### GenData (ai)

Generate and return the data for the DataMatrix bitmap from the input array.

### FillBorder (ai, i, j, k, l)

Fill the border of the ECC200 data matrix bitmap.

### FillCharData (ncol, nrow, array)

Fill the data matrix with the character data in the given message array.
