1. First PB needs UTF8 format, so it is converted from ANSI to UTF8 format to transfer
2. On the receiving side, you need to convert UTF8 to ANSI to use
3. You need to convert SQL from ANSI to UTF8 format before inserting a database
4. The database setting character set is UTF8 ASSERT (0 = = Query (&m_con, "Set NAMES UTF8", strlen ("Set NAMES UTF8" ));
db_user_mail* Pmail = offline->Mutable_user_mail (); ASSERT (Pmail->has_content ());//system mail must be content Char* pcontent = Utf8toansi (pmail->content (). C_STR ()); Charsql[1024x768*Ten] = {0}; sprintf_s (SQL,sizeof(SQL),"INSERT into ' user_sys_mail ' SET ' content ' = '%s ', ' type ' =%d, ' send_time ' = From_unixtime (%u), ' valid_time ' =%u;sel ECT last_insert_id ();", Pcontent, Pmail->type (), Pmail->send_time (), offline->valid_time ()); Free (pcontent); Char* PSQL =ANSIToUTF8 (SQL); intCode =cdbmgr::query (Con, PSQL, strlen (PSQL)); Free (PSQL); if(0! = code)//Non-0 query failed{printf ("Query failed! [%s] [%d] [%s] \ n", SQL, Mysql_errno (con), mysql_error (Con)); return-1; }
Insert the format of Chinese, then this problem brought me a huge disturbance, is the pit.
MySQL Chinese pit daddy stuff