> IMHO, the semantics of encode() and decode() are correct (the bridge
> between bytea and text ... in the backend encoding; they should be the
> only bridge), convert() is also ok (deals with bytes), but
> convert_to() and convert_from() are dubious if not broken: they imply
> texts in arbitrary encodings (for output or input) , lead to
> anomalities and shouldnt be necessary at all.
Sorry, my mistake. I meant the opposite:
convert_to() and convert_from() are the "correct" bridge (text <=>
bytea) functions.
Also convert() is ok.
The objetionable ones IMHO are decode()/encode(), which can
consume/produce a "non-utf8 string" (I mean, not the backend encoding)
Going back to the line:
encode(convert_to(c,'LATIN9'),'escape')
Here we have:
c => text (ut8)
convert_to(..). => bytea (represents a char sequence in latin9 encoding)
encode(...) => text (in latin9 encoding?)
Cheers
Hernán J. González
http://hjg.com.ar/