开发者

Character encoding for Postgres API function return values?

开发者 https://www.devze.com 2023-02-25 09:28 出处:网络
I have a 9.0 postgres server instance and a database using UTF8 character encoding with German_Germany.1252 collation. I\'m trying to get my libpq error messages on the client as US-ASCII strings. To

I have a 9.0 postgres server instance and a database using UTF8 character encoding with German_Germany.1252 collation. I'm trying to get my libpq error messages on the client as US-ASCII strings. To this end I do:

PQsetClientEncoding( connection, "SQL_ASCII" );

which returns no error. However, the strings returned from PQerrorMessage() still seem to be UTF8.

Is the return value from PQerrorMessage always guaranteed to be开发者_如何学Python UTF8? No matter the client/server settings?


SQL_ASCII as a client encoding means, pass the bytes through as is, which is exactly what you didn't want. There actually isn't any client encoding that corresponds to just ASCII. If your messages are in German, then you might want a setting such as LATIN1 or LATIN9. Otherwise change the language to English and the messages will be in ASCII anyway.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号