Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ghbZL-0002iu-Rh for pgsql-general@arkaria.postgresql.org; Thu, 10 Jan 2019 14:44:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ghbZJ-0008A6-US for pgsql-general@arkaria.postgresql.org; Thu, 10 Jan 2019 14:44:25 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ghbZJ-00085f-Ft for pgsql-general@lists.postgresql.org; Thu, 10 Jan 2019 14:44:25 +0000 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) by makus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ghbZG-0000Ze-0c for pgsql-general@postgresql.org; Thu, 10 Jan 2019 14:44:24 +0000 Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:105:465:1:1:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx1.mailbox.org (Postfix) with ESMTPS id DF3E94BAD5; Thu, 10 Jan 2019 15:44:15 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by gerste.heinlein-support.de (gerste.heinlein-support.de [91.198.250.173]) (amavisd-new, port 10030) with ESMTP id ZTl10mYiHv_n; Thu, 10 Jan 2019 15:44:12 +0100 (CET) Message-ID: <2b03726068c6c4f20b41230c3025a52e8bcdffad.camel@cybertec.at> Subject: Re: Error on Windows From: Laurenz Albe To: Igor Korot , pgsql-general Date: Thu, 10 Jan 2019 15:44:11 +0100 In-Reply-To: References: Organization: Cybertec Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Igor Korot wrote: > The following code compiles and executes but returns an error: > > [quote] > Invalid byte sequence for encoding UTF8 > [/quote] > > [code] > char *values[2]; > values[0] = NULL, values[1] = NULL; > values[0] = new char[schemaName.length() + 1]; > values[1] = new char[tableName.length() + 1]; > memset( values[0], '\0', schemaName.length() + 1 ); > memset( values[1], '\0', tableName.length() + 1 ); > strcpy( values[0], m_pimpl->m_myconv.to_bytes( schemaName.c_str() > ).c_str() ); > strcpy( values[1], m_pimpl->m_myconv.to_bytes( tableName.c_str() > ).c_str() ); > int len1 = (int) schemaName.length(); > int len2 = (int) tableName.length(); > int length[2] = { len1, len2 }; > int formats[2] = { 1, 1 }; > PGresult *res = PQexecParams( m_db, m_pimpl->m_myconv.to_bytes( > query.c_str() ).c_str(), 2, NULL, values, length, formats, 1 ); > ExecStatusType status = PQresultStatus( res ); > if( status != PGRES_COMMAND_OK && status != PGRES_TUPLES_OK ) > { > result = 1; > std::wstring err = m_pimpl->m_myconv.from_bytes( > PQerrorMessage( m_db ) ); > errorMsg.push_back( L"Error executing query: " + err ); > PQclear( res ); > } > [/code] > > in the "err" variable. > > Looking under MSVC debugger I see for a tableName a following sequence: > > 97 98 99 223 > > What can I do to eliminate the error? I'd say you should set the client encoding correctly. Looks like the bytes represent "abcß" in some LATIN-? encoding. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com