MySQL Chinese pit daddy stuff

Source: Internet
Author: User
Tags assert psql

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.