How to Convert Bytes code (TBytes) to 874 Thai(Windows) or Thai TIS-620.

Test with Delphi XE10.1 Berlin.

This function show you how to convert TBytes (e.g. Data from Smart card)
to Thai Unicode format.

function แปลง TBytes ไปเป็นข้อความภาษาไทย 874 Thai(Windows) หรือ Thai TIS-620

function GetThaiFromBytesCode(const data: TBytes): WideString;
var
  BYTES_CODE_TH: TBytes;
  UNICODE874_TIS620: TEncoding;
begin
  // UNICODE := TEncoding.GetEncoding('TIS-620');   //TIS-620
  UNICODE874_TIS620 := TEncoding.GetEncoding(874);  //874 Thai(Windows)
  try
    BYTES_CODE_TH := TEncoding.Convert(UNICODE874_TIS620, TEncoding.Unicode, data);
    Result := WideStringOf(BYTES_CODE_TH)
  finally
    UNICODE874_TIS620.Free; //Fixed TMBCSEncoding memory leak.
  end;
end;

Line: mesa.d

Comments