]d2

GS1 DATA TOOL

GS1 scanner-output cleaner

See the AIM symbology identifier separately and preserve meaningful ASCII 29 separators.

01

Inputs

Runs locally
02

Results

]d2

Run the sample to see decoded fields and checks.

ON THIS DEVICE

Recent history

RULES USED

Method and formulas

Recognized three-character AIM prefixes are separated from the payload; common <GS>, {GS} and escaped separator notation is normalized.

Production check

Do not discard a prefix blindly in production-it identifies the decoded symbology and can affect how following data should be interpreted.

GUIDE

What this tool does and when to use it

The GS1 scanner-output cleaner processes raw strings emitted by barcode readers that include AIM code identifiers such as ]C1, ]d2 or ]e0 together with visible representations of the group separator character. It isolates the three-character AIM prefix, removes or normalizes it according to documented rules, and converts tokens such as <GS>, {GS}, \x1D or \u001D into a single consistent representation. The resulting payload begins with the first application identifier and contains properly delimited element strings ready for downstream GS1 parsers. Use this tool after acquiring data from handheld scanners or fixed-mount readers and before passing the string to libraries that expect clean FNC1-terminated data without symbology metadata. The process preserves the original payload length except for the removed prefix and normalized separators, ensuring that subsequent parsing of fixed-length and variable-length AIs proceeds without offset errors. In high-volume environments the cleaner also strips keyboard-wedge artifacts such as stray carriage returns that appear when scanners emulate input devices.

Worked example with realistic scanner output

Consider the input string ]d201095060001343521727123110LOT-2048<GS>21SN00042. The tool first recognizes the leading ]d2 prefix that indicates a Data Matrix symbol decoded under AIM code set d. It separates this prefix and retains it for optional logging while exposing the remaining payload 01095060001343521727123110LOT-2048<GS>21SN00042. Next it locates the <GS> token, replaces it with the actual ASCII 29 character, and yields the normalized element string 01095060001343521727123110LOT-2048 followed by GS 21SN00042. A table illustrates the transformation:

StageContent
Raw scanner output]d201095060001343521727123110LOT-2048<GS>21SN00042
Prefix removed01095060001343521727123110LOT-2048<GS>21SN00042
Separator normalized01095060001343521727123110LOT-2048[GS]21SN00042

The cleaned result can be fed directly to a GS1 element-string parser that expects the first two digits to be the GTIN AI 01.

Second worked example with Code 128 output

A second realistic case begins with ]C101095060001343521727123110LOT-2048\x1D21SN00042. The leading ]C1 prefix signals Code 128 symbology. After prefix extraction the payload becomes 01095060001343521727123110LOT-2048\x1D21SN00042. The hexadecimal escape is converted to ASCII 29, producing 01095060001343521727123110LOT-2048[GS]21SN00042. This output matches the first example exactly, demonstrating that the cleaner normalizes disparate scanner representations into identical byte sequences for consistent downstream parsing.

Formula and method table

Input fieldUnit or formatProcessing ruleOutput field
Raw scanner outputUTF-8 stringMatch leading three-character AIM pattern ^\][A-Za-z0-9]{2}Extracted prefix and remainder
Group separator token<GS>, {GS}, \x1D, \u001DReplace with single ASCII 29Normalized element string
Whitespace sequencesAny run of spaces or tabsCollapse to single space or remove at boundariesTrimmed payload

Units and conversions notes

Scanner outputs use printable surrogates for the non-printable ASCII 29 group separator because many terminals cannot display control characters. The cleaner maps each surrogate to the single byte value 0x1D without altering any surrounding data bytes. No unit conversion occurs because the domain is character encoding rather than physical measurement; however, the tool does convert between hexadecimal escape notation and literal control characters so that parsers receive identical byte sequences regardless of the originating scanner firmware. Fixed-length AIs such as 01 remain exactly fourteen digits after cleaning, while variable-length AIs retain their original content terminated only by the normalized group separator or end of string. Additional rows in the expanded conversion table cover carriage-return removal, tab normalization, and Unicode escape handling.

Input tokenByte valueReplacement ruleResulting byte
<GS>3C 47 53 3ELiteral match and swap0x1D
\x1D5C 78 31 44Hex decode0x1D
\u001D5C 75 30 30 31 44Unicode decode0x1D
{GS}7B 47 53 7DLiteral match and swap0x1D

Limitations

The cleaner does not validate the semantic correctness of application identifiers or check digit calculations; it only performs syntactic normalization of prefixes and separators. If a scanner emits an unrecognized AIM code or an unknown separator representation, the prefix remains attached and may cause the downstream parser to reject the string. The tool operates entirely within the browser and does not transmit data to external services, yet it cannot recover from physical read errors that corrupt the original barcode payload. Production systems must still inspect the retained AIM prefix because certain symbologies require different handling of FNC1 characters after the initial data. The cleaner also ignores any data that follows an unterminated variable-length AI when no group separator appears, and it does not reorder element strings that violate GS1 sequencing recommendations.

Common mistakes

  • Operators sometimes instruct the cleaner to discard the AIM prefix without logging it, losing the information that ]C1 denotes Code 128 while ]d2 denotes Data Matrix; this can affect interpretation of subsequent FNC1 placement rules.
  • Another frequent error is supplying already-cleaned data that contains literal ASCII 29 characters; the tool then treats those bytes as ordinary content and fails to normalize surrounding tokens.
  • Users also overlook leading or trailing whitespace introduced by keyboard wedge interfaces, which the cleaner removes only after prefix extraction, potentially leaving a single space before the first AI if not configured to trim aggressively.
  • Feeding concatenated multi-symbol reads without first splitting on the group separator produces offset errors in fixed-length AI parsing.
  • Assuming every scanner uses the same escape sequence for group separators leads to incomplete normalization when firmware differs.
  • Neglecting to retain the AIM prefix in audit logs removes traceability required by regulated supply-chain applications.
  • Applying the cleaner to non-GS1 barcodes such as raw QR codes containing arbitrary text yields misleading results because no AIM prefix is present.

COMMON QUESTIONS

Frequently asked questions

What does the three-character sequence ]d2 specifically identify in a GS1 scanner string?

The sequence ]d2 is the AIM code identifier for a Data Matrix symbol. Retaining it allows parsers to apply the correct FNC1 handling rules that differ from Code 128 or QR Code symbologies.

How does the cleaner treat a literal ASCII 29 byte that appears inside a variable-length AI value?

The cleaner leaves an actual ASCII 29 byte untouched because it only replaces printable surrogate tokens; an embedded control character inside an AI value indicates a malformed scan that must be rejected by the parser.

Which scanner models commonly emit the token {GS} instead of &lt;GS&gt;?

Certain Honeywell and Zebra firmware versions substitute curly-brace notation when the terminal cannot render control characters; the cleaner maps both {GS} and &lt;GS&gt; to the same ASCII 29 byte.

Does removal of the AIM prefix affect the interpretation of the first application identifier?

No, the first AI always begins immediately after the removed prefix, so 01 remains the GTIN identifier regardless of whether the original prefix was ]C1 or ]d2.

What happens when the input contains multiple consecutive group-separator tokens?

The cleaner collapses runs of separators into single normalized ASCII 29 bytes only when they appear as surrogate tokens; consecutive real control characters are preserved as-is to avoid altering intentionally empty fields.

Can the tool be used on output from linear imagers that never emit AIM prefixes?

Yes, the prefix-matching step simply returns the entire string unchanged when no leading ] sequence is found, allowing the same cleaning pipeline for both 1D and 2D scanner streams.

How should production code handle the retained AIM prefix after cleaning?

Store the prefix separately and consult the AIM specification table to decide whether additional FNC1 insertion or length checks are required before element-string parsing.

What is the maximum input length the cleaner accepts before truncation?

The browser-based implementation processes strings up to 8192 characters; longer payloads are rejected to prevent memory exhaustion in the client-side regular-expression engine.