Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>No special syntax is required so long as:</p> <ul> <li>Your <code>server_encoding</code> includes those characters (if it's <code>utf-8</code> it does);</li> <li>Your <code>client_encoding</code> includes those characters;</li> <li>Your <code>client_encoding</code> correctly matches the encoding of the bytes you're actually sending</li> </ul> <p>The latter is the one that often trips people up. They think they can just change <code>client_encoding</code> with a <code>SET client_encoding</code> statement and it'll do some kind of magical conversion. That is not the case. <code>client_encoding</code> tells PostgreSQL "this is the encoding of the data you will receive from the client, and the encoding that the client expects to receive from you".</p> <p>Setting <code>client_encoding</code> to <code>utf-8</code> doesn't make the client actually send UTF-8. That depends on the client. Nor do you <em>have</em> to send utf-8; that string can also be represented in <code>iso-8859-2</code>, <code>iso-8859-4</code> and <code>iso-8859-10</code> among other encodings.</p> <p>What's crucial is that you tell the server the encoding of the data you're sending. As it happens that string is the same in all three of the encodings mentioned, with the <code>ę</code> encoded as <code>0xae</code>... but in utf-8 that'd be the two bytes <code>0xc4 0x99</code>. If you send utf-8 to the server and tell it that it's <code>iso-8859-2</code> the server can't tell you're wrong and will interpret it as <code>Ä</code> in iso-8859-2.</p> <p>So... really, it depends on things like the system's default encoding, the encoding of any files/streams you're reading data from, etc. You have two options:</p> <ul> <li><p>Set <code>client_encoding</code> appropriately for the data you're working with and the default display locale of the system. This is easiest for simple cases, but harder when dealing with multiple different encodings in input or output.</p></li> <li><p>Set <code>client_encoding</code> to utf-8 (or the same as <code>server_encoding</code>) and make sure that you always convert all input data into the encoding you set <code>client_encoding</code> to before sending it. You must also convert all data you receive from Pg back.</p></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload