By default, the text will be encoded in UTF-8 ecnoding sheme (the BOM is not placed), you can use other encoding scheme, such as the ANSI, UTF-16LE, UTF-16BE, etc.
Method 1, please convert the text to your encoding scheme, then assign it to the Data property of the TBarcodeFmx2D barcode component, such as the TBarcodeFmx2D_QRCode, TBarcodeFmx2D_DataMatrixECC200, and the TBarcodeFmx2D_PDF417. The BOM may be placed depending on your application.
For example:
// The text is encoded in UTF-8 format, and the BOM is placed.
var
BarcodeText: string;
BarcodeData: TBytes;
Len: Integer;
begin
....
BarcodeText := '....';
Len := Length(BarcodeText);
SetLength(BarcodeData, Len * 3 + 3);
BarcodeData[0] := $EF;
BarcodeData[1] := $BB;
BarcodeData[2] := $BF;
Len := UnicodeToUtf8(@BarcodeData[3], Len * 3 + 1, PWideChar(BarcodeText), Len);
if Len > 0 then
SetLength(BarcodeData, Len + 2)
else
SetLength(BarcodeData, 3);
BarcodeFmx2D_QRCode1.Data := BarcodeData;
Method 2, Please create the OnEncode event function for the TBarcodeFmx2D barcode component, such as the TBarcodeFmx2D_QRCode, TBarcodeFmx2D_DataMatrixECC200, and the TBarcodeFmx2D_PDF417. In the event function, you can encode the UNICODE text in your encoding scheme. The BOM may be placed depending on your application.
For example:
var BarcodeText: string;
....
BarcodeText := '....';
BarcodeFmx2D_QRCode1.Barcode := BarcodeText;
....
procedure TForm1.BarcodeFmx2D_QRCode1Encode(Sender: TObject; var Data: TBytes; Barcode: string);
var
Len: Integer;
begin
// The text is encoded in UTF-8 format, and the BOM is placed.
Len := Length(Barcode);
SetLength(Data, Len * 3 + 3);
Data[0] := $EF;
Data[1] := $BB;
Data[2] := $BF;
Len := UnicodeToUtf8(@Data[3], Len * 3 + 1, PWideChar(Barcode), Len);
if Len > 0 then
SetLength(Data, Len + 2)
else
SetLength(Data, 3);
end;