Dear all,

Could it be possible to use the Java Unicode Notation to define UTF-8 
strings in PostgreSQL 7.2.
Information can be found on http://czyborra.com/utf/

Best regards,
Jean-Michel pOURE

************************************************

Java's Unicode Notation
There are some less compact but more readable ASCII transformations the 
most important of which is the Java Unicode Notation as allowed in Java 
source code and processed by Java's native2ascii converter:

putwchar(c)
{
   if (c >= 0x10000) {
     printf ("\\u%04x\\u%04x" , 0xD7C0 + (c >> 10), 0xDC00 | c & 0x3FF);
   }
   else if (c >= 0x100) printf ("\\u%04x", c);
   else putchar (c);
}

The advantage of the \u20ac notation is that it is very easy to type it in 
on any old ASCII keyboard and easy to look up the intended character if you 
happen to have a copy of the Unicode book or the 
{unidata2,names2,unihan}.txt files from the Unicode FTP site or CD-ROM or 
know what U+20AC is the ï¿½.

What's not so nice about the \u20ac notation is that the small letters are 
quite unusual for Unicode characters, the backslashes have to be quoted for 
many Unix tools, the four hexdigits without a terminator may appear merged 
with the following word as in \u00a333 for ï¿½33, it is unclear when and how 
you have to escape the backslash character itself, 6 bytes for one 
character may be considered wasteful, and there is no way to clearly 
present the characters beyond \uffff without \ud800\udc00 surrogates, and 
last but not least the plain hexnumbers may not be very helpful.

JAVA is one of the target and source encodings of yudit and its uniconv 
converter.



Wed, 07 Nov 2001 21:45:42 +0100
Jean-Michel POURE <jm.poure@freesurf.fr>
Java's Unicode Notation
Hi Folks;
    Anyone have a code hack to 7.1 to make postgreSQL break out of the
'sameuser' jail if a user as the 'postgres' superuser flag?  Or maybe to set
config file lines based also on 'superuser' (like 'crypt superuser' or
something like that).  Otherwise I think I might make one.
--
Mike


Wed, 7 Nov 2001 18:58:36 -0400
"Mike Rogers" <temp6453@hotmail.com>
'postgres' flag
"Mike Rogers" <temp6453@hotmail.com> writes:
>     Anyone have a code hack to 7.1 to make postgreSQL break out of the
> 'sameuser' jail if a user as the 'postgres' superuser flag?

The difficulty with that idea is that the connection-matching code has
no idea whether a given userid is superuser or not (indeed, that info
is not available to the postmaster at all).

> Or maybe to set
> config file lines based also on 'superuser' (like 'crypt superuser' or
> something like that).  Otherwise I think I might make one.

Did you read the thread a day or two back in pgsql-admin?  Consider
something like

	local	sameuser	password
	local	all		password crossauth

where crossauth contains the usernames you want to allow to connect
to databases other than their own.

			regards, tom lane

Thu, 08 Nov 2001 09:10:44 -0500
Tom Lane <tgl@sss.pgh.pa.us>
Re: 'postgres' flag 
There appears to be some delay on the list.  I just received that message
this morning (how helpful)- I will be trying to implement it now and see how
far I can get.  It looks like it'll work.  Does it work with 'crypt' or only
'password' (i presently use crypted passwords, but I can change that if
it'll make all the difference)?

    Now the even bigger question- why isn't this documented?
--
Mike

----- Original Message -----
From: "Tom Lane" <tgl@sss.pgh.pa.us>
To: "Mike Rogers" <temp6453@hotmail.com>
Cc: <pgsql-hackers@postgresql.org>
Sent: Thursday, November 08, 2001 10:10 AM
Subject: Re: [HACKERS] 'postgres' flag


> "Mike Rogers" <temp6453@hotmail.com> writes:
> >     Anyone have a code hack to 7.1 to make postgreSQL break out of the
> > 'sameuser' jail if a user as the 'postgres' superuser flag?
>
> The difficulty with that idea is that the connection-matching code has
> no idea whether a given userid is superuser or not (indeed, that info
> is not available to the postmaster at all).
>
> > Or maybe to set
> > config file lines based also on 'superuser' (like 'crypt superuser' or
> > something like that).  Otherwise I think I might make one.
>
> Did you read the thread a day or two back in pgsql-admin?  Consider
> something like
>
> local sameuser password
> local all password crossauth
>
> where crossauth contains the usernames you want to allow to connect
> to databases other than their own.
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>

Thu, 8 Nov 2001 14:11:46 -0400
"Mike Rogers" <temp6453@hotmail.com>
Re: 'postgres' flag
Thank you so much- I have been trying to do exactly that for months (my
postgres and admin users could never see the individual users because we
were using sameuser, unless they were logged in as certain users so that
ident could work- and even then, it's not hard to come from
root@anothermachine or admin@anothermachine).  Thanks so much.  This should
really be documented.  It's not in the sample pg_hba.conf nor the web docs.
--
Mike

----- Original Message -----
From: "Tom Lane" <tgl@sss.pgh.pa.us>
To: "Mike Rogers" <temp6453@hotmail.com>
Cc: <pgsql-hackers@postgresql.org>
Sent: Thursday, November 08, 2001 10:10 AM
Subject: Re: [HACKERS] 'postgres' flag


> "Mike Rogers" <temp6453@hotmail.com> writes:
> >     Anyone have a code hack to 7.1 to make postgreSQL break out of the
> > 'sameuser' jail if a user as the 'postgres' superuser flag?
>
> The difficulty with that idea is that the connection-matching code has
> no idea whether a given userid is superuser or not (indeed, that info
> is not available to the postmaster at all).
>
> > Or maybe to set
> > config file lines based also on 'superuser' (like 'crypt superuser' or
> > something like that).  Otherwise I think I might make one.
>
> Did you read the thread a day or two back in pgsql-admin?  Consider
> something like
>
> local sameuser password
> local all password crossauth
>
> where crossauth contains the usernames you want to allow to connect
> to databases other than their own.
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>

Thu, 8 Nov 2001 14:21:49 -0400
"Mike Rogers" <temp6453@hotmail.com>
Re: 'postgres' flag
Hi,

I'm answering to the original mail, as it has the description itself.

* Jean-Michel POURE <jm.poure@freesurf.fr> [011107 22:04]:
> Dear all,
> 
> Could it be possible to use the Java Unicode Notation to define UTF-8 
> strings in PostgreSQL 7.2.
> Information can be found on http://czyborra.com/utf/
> 
> Best regards,
> Jean-Michel pOURE
> 
> ************************************************
> 
> Java's Unicode Notation
> There are some less compact but more readable ASCII transformations
> the most important of which is the Java Unicode Notation as allowed
> in Java source code and processed by Java's native2ascii converter:
> 
> putwchar(c)
> {
>   if (c >= 0x10000) {
>     printf ("\\u%04x\\u%04x" , 0xD7C0 + (c >> 10), 0xDC00 | c & 0x3FF);
>   }
>   else if (c >= 0x100) printf ("\\u%04x", c);
>   else putchar (c);
> }
> 
> The advantage of the \u20ac notation is that it is very easy to type
> it in on any old ASCII keyboard and easy to look up the intended
> character if you happen to have a copy of the Unicode book or the
> {unidata2,names2,unihan}.txt files from the Unicode FTP site or
> CD-ROM or know what U+20AC is the ï¿œ.
                                    ^^^
Was that the codepoint for the windows proprietary charset for the
Euro, disguised in a mail advertising itself as "iso-8859-1", which
doesn't have the euro sign ? ;)

[No wonder Unicode is really needed in Europe !]

> What's not so nice about the \u20ac notation is that the small
> letters are quite unusual for Unicode characters, the backslashes
> have to be quoted for many Unix tools, the four hexdigits without a
> terminator may appear merged with the following word as in \u00a333
> for ï¿œ33, it is unclear when and how you have to escape the backslash
> character itself, 6 bytes for one character may be considered
> wasteful, and there is no way to clearly present the characters
> beyond \uffff without \ud800\udc00 surrogates, and last but not
> least the plain hexnumbers may not be very helpful.
> 
> JAVA is one of the target and source encodings of yudit and its
> uniconv converter.

I have to disagree about this feature... well, not about the idea, but
the implementation.

First, the use of surrogates to describe > 0x010000 codepoints.
Surrogates are NOT Unicode codepoints. They only exist in UTF-16
encoding, which is the encoding used by Java and Windows. However,
PostgreSQL, as most Unix tools, uses UTF-8 as encoding.

Encoding codepoints over 0xffff with two surrogates in UTF-8 is
illegal... So, you should forget about this, as this is an unnatural
extra step.

I've seen somewhere the notation \v010000 (using \v for 6-char
codepoints). But I don't like it too much either.

I agree with your idea of being able to express unicode codepoints
directly with escape characters. I personally like Perl's solution :

\x{20ac}
\x{010123}
\x{7e}

Using the braces, it makes it unambiguous to deal with codepoint
length (I've often myself put one "0" too much or not enough in
unicode code point descriptions).

I don't mind \u{...} instead of \x{...}. But a lot of PostgreSQL users
would be familiar with \x{} notation :) [Me being the first one]

I think that this is something for psql however. Where is "\n"
translated, for example ? Anyway, for 7.3... :)

Patrice.

-- 
Patrice Hï¿œdï¿œ
email: patrice hede ï¿œ islande org
www  : http://www.islande.org/

Mon, 12 Nov 2001 19:03:14 +0100
Patrice =?iso-8859-15?Q?H=E9d=E9?= <phede-ml@islande.org>
Re: Java's Unicode Notation