Encoding fails when inserting a character string contains 2-Byte ANSI character, e. g. '"üäö".
Encoding is OK if the character string contains at least one 2-Byte NON ANSI character, e. g. "П"

Dear Mr. Rao, can you confirm the behavior?
Encoding is OK if the character string contains at least one 2-Byte NON ANSI character, e. g. "П"
#include "fivewin.ch"
STATIC aStr := { "127.0.0.1, test, root, frose2023", ;
"208.91.198.197:3306,fwhdemo,gnraofwh,Bharat@1950", ;
"209.250.245.152,fwh,fwhuser,FiveTech@2022" }
STATIC oCn
REQUEST HB_CODEPAGE_UTF8
FUNCTION Main()
LOCAL oRs
LOCAL cTable := "test"
LOCAL cVar1 := "üäö"
FW_SetUnicode( .T. )
oCn := maria_Connect( aStr[ 1 ], .T. )
oCn:bOnLostServer := { || Alert( "Connection lost! Try again" ), .T. }
MsgRun( "Creating Test Table.............", "PLEASE WAIT .......", { || CreateSampleTable( cTable, .T. ) } )
// Encoding is NOT ok with 2-Byte ANSI character
oCn:Insert( cTable, { "test", "StrToHex" }, { cVar1, StrToHex( cVar1, " " ) }, )
// Encoding is ok with 2-Byte NON ANSI character
oCn:Insert( cTable, { "test", "StrToHex" }, { cVar1 + " П", StrToHex( cVar1 + " |П", " " ) }, )
oRs := oCn:RowSet( "SELECT * FROM `" + cTable + "`", .F. )
XBrowse( oRs )
RETURN NIL
STATIC FUNCTION CreateSampleTable( cTable, lDrop )
LOCAL cSql := ""
LOCAL uResult
Default lDrop := .F.
//
IF lDrop .OR. !oCn:TableExists( cTable )
cSql += CRLF + "SET NAMES utf8mb4;"
cSql += CRLF + "SET FOREIGN_KEY_CHECKS = 0;"
cSql += CRLF + "DROP TABLE IF EXISTS `" + cTable + "`;"
cSql += CRLF + "CREATE TABLE `" + cTable + "` ("
cSql += CRLF + " `test` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '',"
cSql += CRLF + " `StrToHex` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '',"
cSql += CRLF + " `guid` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT uuid(),"
cSql += CRLF + " `createdt` timestamp NOT NULL DEFAULT current_timestamp(),"
cSql += CRLF + " `modifydt` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP,"
cSql += CRLF + " PRIMARY KEY (`GUID`) USING BTREE"
cSql += CRLF + ") ENGINE = MyISAM CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;"
cSql += CRLF + "SET FOREIGN_KEY_CHECKS = 1;"
uResult := oCn:Execute( cSql,, .T. )
ENDIF
RETURN NIL
Dear Mr. Rao, can you confirm the behavior?
Windows 11 Pro 22H2 22621.1848
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Harbour 3.2.0dev (r2008190002)
FWH 23.10 x86
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Harbour 3.2.0dev (r2008190002)
FWH 23.10 x86