473,800 Members | 2,741 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Confused with db client encoding

Hi,

Here is the output a psql session. Please notice that the identation
inconsistences in the records containg non ASCII chars is as outputed by
psql.

The db was created with LANIN9 and the console was ran (in the same
machine) using UTF-8 (my system's default).

I was surprised to notice that setting the client to unicode (which is
what that console is using) messed the localized chars as I was
expecting to see the opposite way.

On the other way, when invoking from a Java app, running on the same
machine, the accentuaded chars also appeared messed.

Have I misunderstood the manual? How can I get a consistant behaviour?

It was tested in a Debian/unstable box, running PostgreSQL 7.4.5-3 and
Sun's JVM 1.4.2

Thanks,

Carlos

psql session:
-----
mpb2-m16e=# \l
List of databases
Name | Owner | Encoding
-----------+----------+----------
mpb2-test | carlos | LATIN9
template0 | postgres | LATIN9
template1 | postgres | LATIN9
(3 rows)

mpb2-m16e=# select tipo_doc_id, nome, descricao from tab_tipo_doc where
tipo_doc_id < 100;
tipo_doc_id | nome | descricao
-------------+----------------------+---------------------------------------
0 | | (documento desconhecido)
1 | Encomenda | Encomendas
2 | Factura | Facturas
3 | Tx. Dinheiro | Transacções a Dinheiro
11 | Nota de Crédito | Notas de Crédito
12 | Nota de Débito | Notas de Débito
21 | G. Remessa | Guia de Remessa
91 | SaÃ*da Armazém | SaÃ*das de Armazém
92 | Ent. Armazém | Entradas em Armazém
5 | Devolução | Devoluções de Facturas/Tx. Dinheiro
99 | Acerto Inv. | Acerto de Inventário
51 | O.T. | Ordens de Trabalho
(12 rows)

mpb2-m16e=# set client_encoding to unicode;
SET
mpb2-m16e=# select tipo_doc_id, nome, descricao from tab_tipo_doc where
tipo_doc_id < 100;
tipo_doc_id | nome | descricao
-------------+----------------------+---------------------------------------
0 | | (documento desconhecido)
1 | Encomenda | Encomendas
2 | Factura | Facturas
3 | Tx. Dinheiro | Transacçõ es a Dinheiro
11 | Nota de Crédito | Notas de Crédito
12 | Nota de Débito | Notas de Débito
21 | G. Remessa | Guia de Remessa
91 | SaÃÂ*da Armazém | SaÃÂ*das de Armazém
92 | Ent. Armazém | Entradas em Armazém
5 | Devolução | Devoluçõe s de Facturas/Tx.
Dinheiro
99 | Acerto Inv. | Acerto de Inventário
51 | O.T. | Ordens de Trabalho
(12 rows)


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 23 '05 #1
1 2645
On Mon, 06 Sep 2004 00:02:24 +0100, Carlos Correia <ca****@m16e.co m> wrote:
Hi,

Here is the output a psql session. Please notice that the identation
inconsistences in the records containg non ASCII chars is as outputed by
psql.

The db was created with LANIN9 and the console was ran (in the same
machine) using UTF-8 (my system's default).

I was surprised to notice that setting the client to unicode (which is
what that console is using) messed the localized chars as I was
expecting to see the opposite way.

On the other way, when invoking from a Java app, running on the same
machine, the accentuaded chars also appeared messed.
(...) 3 | Tx. Dinheiro | Transacções a Dinheiro
11 | Nota de Crédito | Notas de Crédito
12 | Nota de Débito | Notas de Débito
21 | G. Remessa | Guia de Remessa


It looks like this data was entered as UTF-8 but the client encoding
was LATIN9 (or whatever), meaning the two incoming bytes from each
accentuated character in UTF-8 was interpreted by the backend as two
individual bytes in LATINx.

Test case (session in a UTF-8 environment):

test=# CREATE DATABASE ctest encoding 'LATIN1';
CREATE DATABASE
test=# \c ctest;
You are now connected to database "ctest".
ctest=# CREATE TABLE coding (data TEXT);
CREATE TABLE
ctest=# SET client_encoding TO LATIN1;
SET
ctest=# INSERT INTO coding VALUES('müller' );
INSERT 349960 1
ctest=# SELECT * FROM coding;
data
---------
müller
(1 row)

ctest=# SET client_encoding TO UNICODE;
SET
ctest=# SELECT * FROM coding;
data
---------
müller
(1 row)

Ian Barwick

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postg resql.org

Nov 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2381
by: Unbreakable | last post by:
I am using the nusoap client and nusoap server without any problem. However, once I change the client to the excel, I am not sure how to call the nusoap server. Especially the nusoap server only generate the a SOAP message as follow instead of a WSDL file. So, my question is 1.) Can I use excel or .Net as a client to call the nusoap server?
0
2206
by: Anand Natrajan | last post by:
Hi! I have a VB .NET client that is accessing an rpc/encoded service deployed in Axis 1.2. One of the operations, whoami, returns a string array. The server-side Java signature of this method is String whoami(MyPrincipal principal) My .NET client is unable to access the results of that array. The odd thing is that the very same client was able to access the results when the same service was deloyed in Axis 1.1. I've asked the Axis folks...
4
1333
by: Ian Harding | last post by:
I'm working on a .NET application that requests an XML document, in string form, from a legacy COM component, then deserializes it. In order to deserialize the document, the string needs to be placed into a stream. AFAIK, .NET strings are UTF-16 encoded, but the COM component returns a UTF-8 encoded document, so my first attempt at creating and filling a stream used this code: string response = <some UTF-8 encoded xml from a COM...
0
2170
by: Harley | last post by:
Hello, I am just learning the tcp/ip functions etc under vb.net so please look over me if this is obviouse. I have been all over looking into any functions that I didn't totaly understand and can't see that I am doing anything wrong (i obviousely am though) everything "works", client connects to server and when anything is sent to the server it starts the mp3 and passes all messages the way i ment for it to except that my server is...
7
4989
by: Christian Wilhelm | last post by:
Hi! I'm trying to call a Java WebService out of a .net Client. There are two Methods, one Method requires one Parameter of type Parameter, the other Method requires one Parameter of type Parameter. I can call the first Method without Problems, the Parameter can be deserialized by the WebService. But if I want to call the second Method and give it an Array of Parameters, then the following exception is thrown by the WebService:...
0
1944
by: helldiversafe-news | last post by:
Hi all, I will use a apache soap service with an .net c# client and have a problem with an complex array: <?xml version='1.0' encoding='UTF-8'?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <SOAP-ENV:Body>
14
4453
by: Ankit Aneja | last post by:
The code of classes given below is for server to which clients connect i want to get ip address of client which has connected pls help how can i get //listen class public class listen {
0
1050
by: Pascal Flückiger | last post by:
Hello I have a tcl-webservice based on tclsoap/tclhttpd. A function returns an array of structs. The problem (someone from csharp.de ng told me): The Soap-functionality of the .Net Framework does not support Arrays of Structures.. but it would accept arrays of classes. On tcl-side i have no classes.... any ideas?
0
2092
by: Ontrace | last post by:
hello, I have Problem with Client Server Application when I unplug the client network cable, the server still read the network stream what function should I use to make server detect that the client is disconnect here the code... serverSide
0
9690
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10501
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10273
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10032
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2944
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.