When I create account will enter the name as , Chinese VS feedback account creation failed, but the command statement directly used in MySQL, create success,
Originally I thought it was the code there is an error, but after several attempts, I found a name other than Chinese, using English and Numbers can create success ,
Online to find information, said vs. the default character set GBK, MySQL default character set for utf-8, intermediate conversion will be garbled, then I will find information
Vs. the default character set to utf-8, the result is fail,
Request, help!!!!!!
sprintf_s (s, "INSERT INTO ` student_info ` (` id `, ` password `, ` name `, ` type `) VALUES (' % s', '% s',' % s', 'student');"
, login_account login_password, login_name);
Const char * insert=s;//MySQL function called the type of need for const char *
if (! Mysql_query (login, insert))
{
Cout & lt; <"T \ t \ n \ n " & lt; <"Account creation success" & lt;Cout & lt; <"T \ t \ n " & lt; }
The else
{
Cout & lt; <"T \ t \ n \ n " & lt; <"Create failure" & lt;Cout & lt; <"T \ t \ n " & lt; }
CodePudding user response:
You need to put the string into utf8 encoding, not your vs document to utf8