2002-04-15 00:12:54 +00:00
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
2007-06-20 22:25:43 +00:00
|
|
|
<!-- $Revision: 1.11 $ -->
|
2002-04-15 00:12:54 +00:00
|
|
|
<!-- splitted from ./en/functions/pgsql.xml, last change in rev 1.16 -->
|
2007-06-20 22:25:43 +00:00
|
|
|
<refentry xml:id="function.pg-set-client-encoding" xmlns="http://docbook.org/ns/docbook">
|
2005-03-08 00:06:33 +00:00
|
|
|
<refnamediv>
|
|
|
|
<refname>pg_set_client_encoding</refname>
|
|
|
|
<refpurpose>
|
|
|
|
Set the client encoding
|
|
|
|
</refpurpose>
|
|
|
|
</refnamediv>
|
2005-03-11 16:03:26 +00:00
|
|
|
|
|
|
|
<refsect1 role="description">
|
|
|
|
&reftitle.description;
|
2005-03-08 00:06:33 +00:00
|
|
|
<methodsynopsis>
|
|
|
|
<type>int</type><methodname>pg_set_client_encoding</methodname>
|
|
|
|
<methodparam><type>string</type><parameter>encoding</parameter></methodparam>
|
|
|
|
</methodsynopsis>
|
|
|
|
<methodsynopsis>
|
|
|
|
<type>int</type><methodname>pg_set_client_encoding</methodname>
|
|
|
|
<methodparam><type>resource</type><parameter>connection</parameter></methodparam>
|
|
|
|
<methodparam><type>string</type><parameter>encoding</parameter></methodparam>
|
|
|
|
</methodsynopsis>
|
|
|
|
<para>
|
|
|
|
<function>pg_set_client_encoding</function> sets the client
|
|
|
|
encoding and returns 0 if success or -1 if error.
|
|
|
|
</para>
|
|
|
|
<para>
|
2005-07-04 09:00:59 +00:00
|
|
|
PostgreSQL will automatically convert data in the backend database
|
|
|
|
encoding into the frontend encoding.
|
2005-03-08 00:06:33 +00:00
|
|
|
</para>
|
|
|
|
<note>
|
|
|
|
<para>
|
|
|
|
The function used to be called
|
2005-04-21 09:29:36 +00:00
|
|
|
<function>pg_setclientencoding</function>.
|
2005-03-08 00:06:33 +00:00
|
|
|
</para>
|
|
|
|
</note>
|
2005-03-11 16:03:26 +00:00
|
|
|
</refsect1>
|
|
|
|
|
2005-07-04 09:00:59 +00:00
|
|
|
<refsect1 role="parameters">
|
|
|
|
&reftitle.parameters;
|
|
|
|
<para>
|
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>connection</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
PostgreSQL database connection resource. When
|
|
|
|
<parameter>connection</parameter> is not present, the default connection
|
|
|
|
is used. The default connection is the last connection made by
|
|
|
|
<function>pg_connect</function> or <function>pg_pconnect</function>.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>encoding</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
The required client encoding. One of <literal>SQL_ASCII</literal>, <literal>EUC_JP</literal>,
|
|
|
|
<literal>EUC_CN</literal>, <literal>EUC_KR</literal>, <literal>EUC_TW</literal>,
|
|
|
|
<literal>UNICODE</literal>, <literal>MULE_INTERNAL</literal>, <literal>LATINX</literal> (X=1...9),
|
|
|
|
<literal>KOI8</literal>, <literal>WIN</literal>, <literal>ALT</literal>, <literal>SJIS</literal>,
|
|
|
|
<literal>BIG5</literal> or <literal>WIN1250</literal>.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
The exact list of available encodings depends on your PostgreSQL version, so check your
|
|
|
|
PostgreSQL manual for a more specific list.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="returnvalues">
|
|
|
|
&reftitle.returnvalues;
|
|
|
|
<para>
|
|
|
|
Returns 0 on success or -1 on error.
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
2005-09-05 04:07:19 +00:00
|
|
|
|
|
|
|
<refsect1 role="examples">
|
|
|
|
&reftitle.examples;
|
|
|
|
<para>
|
|
|
|
<example>
|
|
|
|
<title><function>pg_set_client_encoding</function> example</title>
|
|
|
|
<programlisting role="php">
|
|
|
|
<![CDATA[
|
|
|
|
<?php
|
|
|
|
|
|
|
|
$conn = pg_pconnect("dbname=publisher");
|
|
|
|
if (!$conn) {
|
|
|
|
echo "An error occured.\n";
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set the client encoding to UNICODE. Data will be automatically
|
|
|
|
// converted from the backend encoding to the frontend.
|
|
|
|
pg_set_client_encoding($conn, UNICODE);
|
|
|
|
|
|
|
|
$result = pg_query($conn, "SELECT author, email FROM authors");
|
|
|
|
if (!$result) {
|
|
|
|
echo "An error occured.\n";
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write out UTF-8 data
|
|
|
|
while ($row = pg_fetch_row($result)) {
|
|
|
|
echo "Author: $row[0] E-mail: $row[1]";
|
|
|
|
echo "<br />\n";
|
|
|
|
}
|
2005-07-04 09:00:59 +00:00
|
|
|
|
2005-09-05 04:07:19 +00:00
|
|
|
?>
|
|
|
|
]]>
|
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
2005-03-11 16:03:26 +00:00
|
|
|
<refsect1 role="seealso">
|
|
|
|
&reftitle.seealso;
|
2005-03-08 00:06:33 +00:00
|
|
|
<para>
|
2005-03-11 16:03:26 +00:00
|
|
|
<simplelist>
|
|
|
|
<member><function>pg_client_encoding</function></member>
|
|
|
|
</simplelist>
|
2005-03-08 00:06:33 +00:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
2002-04-15 00:12:54 +00:00
|
|
|
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
|
|
Local variables:
|
|
|
|
mode: sgml
|
|
|
|
sgml-omittag:t
|
|
|
|
sgml-shorttag:t
|
|
|
|
sgml-minimize-attributes:nil
|
|
|
|
sgml-always-quote-attributes:t
|
|
|
|
sgml-indent-step:1
|
|
|
|
sgml-indent-data:t
|
|
|
|
indent-tabs-mode:nil
|
|
|
|
sgml-parent-document:nil
|
|
|
|
sgml-default-dtd-file:"../../../../manual.ced"
|
|
|
|
sgml-exposed-tags:nil
|
|
|
|
sgml-local-catalogs:nil
|
|
|
|
sgml-local-ecat-files:nil
|
|
|
|
End:
|
|
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
|
|
vim: et tw=78 syn=sgml
|
|
|
|
vi: ts=1 sw=1
|
|
|
|
-->
|