加两个东西:
mysql_set_character_set(mysql, “utf8”);
UTF8_TO_TCHAR()
在这里插入图片描述
MYSQL* mysql = new MYSQL;
mysql_init(mysql);
MYSQL_RES* result;
MYSQL_ROW row;
if (mysql_real_connect(mysql, "localhost", "root", "root", "java", 3306, NULL, 0)) {
mysql_set_character_set(mysql, "utf8");//这里
int i = mysql_query(mysql, "select * from user");
result = mysql_store_result(mysql);
while ((row = mysql_fetch_row(result)) != NULL)
{
/*std::cout << "id=" << row[0];
std::cout << "name=" << row[1] << "\n";*/
GEngine->AddOnScreenDebugMessage(-1, 10.0f, FColor::Yellow, FString::Printf(TEXT("Hello world, this is %s"), UTF8_TO_TCHAR(row[0])), true);//和这里
GEngine->AddOnScreenDebugMessage(-1, 10.0f, FColor::Yellow, FString::Printf(TEXT("Hello world, this is %s"), UTF8_TO_TCHAR(row[1])), true);
//GEngine->AddOnScreenDebugMessage(0, 5.0f, FColor::Yellow, TEXT("row= %s"), row[1]);
}
}
else {
/*std::printf("sb");*/
GEngine->AddOnScreenDebugMessage(0, 5.0f, FColor::Yellow, TEXT("sb"));
}
mysql_close(mysql);
return nullptr;