Subject Re: Character set was RE: Digest Number 1619
Author peter_jacobi.rm
Hi p_lerner,

--- In firebird-support@yahoogroups.com, "p_lerner" wrote:
> Well, I'm sorry to be remembering you to Forest Gump,

Don't be worried, the first 1000 hours fighting against
charset issues always look stupid.

> Definitions:
> oldFld: varchar(70) CHARSET: NONE COLLATION: NONE
> newFld: varchar(70) CHARSET: ISO8859-1 COLLATION: ES_ES

Answering without actually trying in ISQL (which is very
dangerous, but I hope I'm lucky):

> "UPDATE ordcompra
> set newFld = ISO8859_1 oldFld
> where oldFld is not null"
[...]
> The problem is that I get :
> "Invalid token.
[...]

This is only syntactic hickup, use _ISO8859_1
instead.

> I also have try:
> "update ordcompra
> set prueba = cast(orc_motivo as VARCHAR(70) CHARACTER SET ISO8859_1)
> where orc_motivo is not null"
>
> but I get:
> "Arithmetic overflow or division by zero has occurred.
> arithmetic exception, numeric overflow, or string truncation.
> Cannot transliterate character between character sets."

This is correctly flagged illegal, as there is now way to
transliterate a string of unknown character encoding.

Your first try is better. You would have to combine both
forms if you knew the characer encoding in the oldFld and
it differs from the desired character encoding, this would
be something like:

set newFld = cast (_CP437 oldFld as VARCHAR(70) CHARACTER SET ISO8859_1)

Regards,
Peter Jacobi