cannot insert unicode value in table (Mydac 9.1.3 for RAD Studio 10.2)

cannot insert unicode value in table (Mydac 9.1.3 for RAD Studio 10.2)

Hi,
I have create a very simple database to test inserting unicode characters:

  1. CREATE TABLE `tencodingtest` (
  2.   `pk` int(11) NOT NULL AUTO_INCREMENT,
  3.   `value_as_utf8` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  4.   `value_as_utf16` varchar(30) CHARACTER SET utf16 COLLATE utf16_unicode_ci DEFAULT NULL,
  5.   `normalvarchar` varchar(30) DEFAULT NULL,
  6.   PRIMARY KEY (`pk`)
  7. ) ENGINE=MyISAM DEFAULT CHARSET=latin1 

In my test, I want to try to insert this character into the field 'value_as_utf8': Unicode Character “𠀋” (U+2000B).  
This character in UTF-8 is:  0xF0 0xA0 0x80 0x8B
This character in UTF-16 is: 0xD840 0xDC0B 


I have made several attempts to insert this value with this function, but all attempts fail:

  1. procedure TfmDatabase.Button5Click(Sender: TObject);
  2. var
  3.   s: String;
  4.   s8: UTF8String;
  5. begin
  6.   MyConnection1.Connected := False;
  7.   MyConnection1.Options.UseUnicode := True; //IMPORTANT!!
  8.   MyConnection1.Connect;

  9.   MyQuery2.SQL.Text := 'select * from tencodingtest';
  10.   MyQuery2.Execute;

  11.   s := '𠀋';
  12.   s8 := '𠀋';
  13.   //---[ATTEMPT 1]
  14.   try
  15.     MyQuery2.Append;
  16.     MyQuery2.FieldByName('value_as_utf16').AsString := s;
  17.     MyQuery2.Post;
  18.   except on e: Exception do
  19.     begin
  20.       MyQuery2.Cancel;
  21.       mmLog.Lines.Add('[ATTEMPT 1]: Exception: ' + e.Message);
  22.     end;
  23.   end;

  24.   //---[ATTEMPT 2]
  25.   try
  26.     MyQuery2.Append;
  27.     MyQuery2.FieldByName('value_as_utf8').AsString := s;
  28.     MyQuery2.Post;
  29.   except on e: Exception do
  30.     begin
  31.       MyQuery2.Cancel;
  32.       mmLog.Lines.Add('[ATTEMPT 2]: Exception: ' + e.Message);
  33.     end;
  34.   end;

  35.   //---[ATTEMPT 3]
  36.   try
  37.     MyQuery2.Append;
  38.     MyQuery2.FieldByName('value_as_utf8').AsString := s8;
  39.     MyQuery2.Post;
  40.   except on e: Exception do
  41.     begin
  42.       MyQuery2.Cancel;
  43.       mmLog.Lines.Add('[ATTEMPT 3]: Exception: ' + e.Message);
  44.     end;
  45.   end;

  46.   //---[ATTEMPT 4]
  47.   try
  48.     MyQuery2.Append;
  49.     MyQuery2.FieldByName('value_as_utf8').AsWideString := s8;
  50.     MyQuery2.Post;
  51.   except on e: Exception do
  52.     begin
  53.       MyQuery2.Cancel;
  54.       mmLog.Lines.Add('[ATTEMPT 4]: Exception: ' + e.Message);
  55.     end;
  56.   end;

  57.   //---[ATTEMPT 5]
  58.   try
  59.     MyQuery2.Append;
  60.     MyQuery2.FieldByName('value_as_utf8').AsWideString := s;
  61.     MyQuery2.Post;
  62.   except on e: Exception do
  63.     begin
  64.       MyQuery2.Cancel;
  65.       mmLog.Lines.Add('[ATTEMPT 5]: Exception: ' + e.Message);
  66.     end;
  67.   end;

  68. end;

All 5 attempts fail with these results:
[ATTEMPT 1]: Exception: #HY000Incorrect string value: '\xF0\xA0\x80\x8B' for column 'value_as_utf16' at row 1
[ATTEMPT 2]: Exception: #HY000Incorrect string value: '\xF0\xA0\x80\x8B' for column 'value_as_utf8' at row 1
[ATTEMPT 3]: Exception: #HY000Incorrect string value: '\xF0\xA0\x80\x8B' for column 'value_as_utf8' at row 1
[ATTEMPT 4]: Exception: #HY000Incorrect string value: '\xF0\xA0\x80\x8B' for column 'value_as_utf8' at row 1
[ATTEMPT 5]: Exception: #HY000Incorrect string value: '\xF0\xA0\x80\x8B' for column 'value_as_utf8' at row 1

I tried inserting this character just with a 3rd party editor (HeidiSql), and it can be inserted without problems in both fields (value_as_utf8 and value_as_utf16) (see attachment please).


Am I doing something wrong why this is not working from Delphi?

Mydac Version = 9.1.3 for RAD Studio 10.2.

Regards, Vincent