IRONSOFTWAREHOME
Override ECI Encoding for One Barcode
using IronBarCode;

// Application-wide policy
BarcodeWriter.DefaultEciMode = EciMode.Auto;

// Per-call EciMode overrides the default for this barcode only
GeneratedBarcode compliance = DataMatrixWriter.CreateDataMatrix("LOT-4471-A", 200, EciMode.ForceUtf8);
compliance.SaveAsPng("compliance-label.png");

// No argument, so this one follows the default
GeneratedBarcode standard = DataMatrixWriter.CreateDataMatrix("LOT-4471-B", 200);
standard.SaveAsPng("standard-label.png");
NuGet Download
PM > Install-Package BarCode
Override ECI Encoding for One Barcode

Override ECI Encoding for One Barcode

Most applications want a single ECI policy across every barcode they produce, but occasionally one symbol has to differ. A label bound for a compliance system may need to declare its encoding explicitly while the rest of the output stays compact. The CreateDataMatrix overloads accept an EciMode argument for exactly this case, overriding the application-wide default for that one call.

4-Step Guide to Overriding ECI Encoding for One Barcode

  • using IronBarCode;
  • BarcodeWriter.DefaultEciMode = EciMode.Auto;
  • GeneratedBarcode compliance = DataMatrixWriter.CreateDataMatrix("LOT-4471-A", 200, EciMode.ForceUtf8);
  • GeneratedBarcode standard = DataMatrixWriter.CreateDataMatrix("LOT-4471-B", 200);

Code Explanation

We first import the IronBarcode library and set BarcodeWriter.DefaultEciMode to EciMode.Auto, the application-wide policy under which a header is written only when the data needs one.

The first CreateDataMatrix call passes EciMode.ForceUtf8 as its third argument. A per-call value wins over the static default, so this symbol carries the UTF-8 ECI header even though its payload is pure ASCII. The override applies to that call alone and leaves the application policy untouched.

The second call passes no encoding argument. It falls back to DefaultEciMode, so its ASCII payload produces the smaller untagged symbol. Only DataMatrixWriter.CreateDataMatrix offers this per-call parameter; QR, Aztec and PDF417 follow the static default instead.

Explore the full guide to controlling UTF-8 ECI tagging!

Ready to Get Started?

Nuget Downloads 2,452,240Version:2026.9just released

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

OR
bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried Iron Suite
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required