PostgreSQL: declare cursor failed: Error: Invalid byte sequence for encoding "utf8": 0x

Source: Internet
Author: User

Question: PostgreSQL needs to be used in VC. ODBC is used in the first place. I want to use other methods because I feel the configuration is troublesome. We can see that libpq ++ can be used at the beginning, but the version of libpqxx is no longer available after. Others also say that libpqxx is used, but those makefiles are hard to get, it seems that a specific vs version is required for compilation, so libpq is used in simplicity, because only simple functions are used.

 

Problem description: PostgreSQL: declare cursor failed: Error: Invalid byte sequence for encoding "utf8": 0xc9e3

Cause: because the Chinese table name is used, the SELECT statement also has Chinese characters. When constructing strsql, cstring and cstring are ASCII encoded, even if _ T ("") is added as Unicode encoding, you must convert it to utf8 to pqexec () or change the table name to English.

 

BTW: int nres = pqsetclientencoding (Conn, "SQL _ascii"); // sets the client encoding.
Const char * chcode = pg_encoding_to_char (pqclientencoding (conn); // view the client Encoding

This document is not easy to understand.

 

Related Article

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.