By default, the text will be encoded in ANSI ecnoding sheme, you can use other encoding scheme, such as the UTF-8, UTF-16LE, UTF-16BE, etc.
Note, the feature isn't supported by almost barcode scanners.
For Delphi/C++ Builder 2007 or early:
Method 1, please convert the text to your encoding scheme, then assign it to the Barcode property of the barcode component. The BOM may be placed depending on your application. And then create the OnDecodeText event function in order to decode the barcode text from your encoding string and output it into the symbol.
For the TBarcode1D_Code128 component, please change the AutoCheckDigit property to true. For the TBarcode1D_EAN128 component, please change the AutoCheckDigit property to false.
For example:
var BarcodeText: string;
....
BarcodeText := '....';
// The text is encoded in UTF-8 format, and the BOM is placed.
Barcode1D_Code1281.AutoCheckDigit := True;
Barcode1D_Code1281.Barcode := #$EF#$BB#$BF + AnsiToUTF8(BarcodeText);
....
procedure TForm1.Barcode1D_Code1281DecodeText(Sender: TObject; var BarcodeText: string; Data: AnsiString);
begin
// Remove the BOM before decoding.
BarcodeText := UTF8ToAnsi(Copy(Data, 4, Length(Data) - 3);
end;
Method 2, Please create the OnEncode event function for the barcode component. In the event function, you can encode the UNICODE text in your encoding scheme. The BOM may be placed depending on your application.
For the TBarcode1D_Code128 component, please change the AutoCheckDigit property to true. For the TBarcode1D_EAN128 component, please change the AutoCheckDigit property to false.
For example:
var BarcodeText: string;
....
BarcodeText := '....';
Barcode1D_Code1281.AutoCheckDigit := True;
Barcode1D_Code1281.Barcode := BarcodeText;
....
procedure TForm1.Barcode1D_Code1281Encode(Sender: TObject; var Data: AnsiString; Barcode: string);
begin
// The text is encoded in UTF-8 format, and the BOM is placed.
Data := #$EF#$BB#$BF + AnsiToUTF8(Barcode);
end;
For Delphi/C++ Builder 2009 or later:
Method 1, please convert the text to your encoding scheme, then assign it to the Data property of the barcode component. The BOM may be placed depending on your application. And then create the OnDecodeText event function in order to decode the barcode text from your encoding string and output it into the symbol.
For the TBarcode1D_Code128 component, please change the AutoCheckDigit property to true. For the TBarcode1D_EAN128 component, please change the AutoCheckDigit property to false.
For example:
// The text is encoded in UTF-8 format, and the BOM is placed.
var BarcodeText: string;
....
BarcodeText := '....';
Barcode1D_Code1281.AutoCheckDigit := True;
Barcode1D_Code1281.Data := #$EF#$BB#$BF + UTF8Encode(BarcodeText);
....
procedure TForm1.Barcode1D_Code1281DecodeText(Sender: TObject; var BarcodeText: string; Data: AnsiString);
begin
// Remove the BOM before decoding.
BarcodeText := UTF8Decode(Copy(Data, 4, Length(Data) - 3);
end;
Method 2, Please create the OnEncode event function for the barcode component. In the event function, you can encode the UNICODE text in your encoding scheme. The BOM may be placed depending on your application.
For the TBarcode1D_Code128 component, please change the AutoCheckDigit property to true. For the TBarcode1D_EAN128 component, please change the AutoCheckDigit property to false.
For example:
var BarcodeText: string;
....
BarcodeText := '....';
Barcode1D_Code1281.AutoCheckDigit := True;
Barcode1D_Code1281.Barcode := BarcodeText;
....
procedure TForm1.Barcode1D_Code1281Encode(Sender: TObject; var Data: AnsiString; Barcode: string);
begin
// The text is encoded in UTF-8 format, and the BOM is placed.
Data := #$EF#$BB#$BF + UTF8Encode(Barcode);
end;