Subject Re: [ib-support] character sets and arrays and blobs
Author Ann W. Harrison
At 11:37 AM 10/27/2001 +1000, Geoff Worboys wrote:

>...a search of the API reference for
>"character set" does not show any means of specifying alternative
>character sets for non-blob text fields.

The documentation is wrong. dsql_describe returns a value for
sqlsubtype on normal character fields that use a specific character
set and collation. In the case below it was ISO8859_1 FR_FR.


sqlvar 0x008d1ac4
[0] {...}
sqltype 449
sqlscale 0
sqlsubtype 1045
sqllen 15

I think that if you use the appropriate subtype on input,
even for fields that have been defined as character set NONE
it will all work.


> > >Is anyone able to tell me whether it always OK to
> > >simply read/write blobs without application of
> > >matching character set filters?
>
> > Yes.

>This is convenient for me, but it does seem inconsistent with the
>normal text fields.

OK, let me check the code. All the character set stuff was
introduced after my time. I've had it explained a dozen times
but retain only a little and much of that incorrect. Ah yes.
When you open a blob, you set a structure called a bdb (blob
descriptor block) to indicate the desired output type. InterBase
automatically filters from the input to the output type. Some
relevant code follows.

> > >Arrays...
><...>
> > No, it reflects the general disregard for blobs. However,
> > array data will be transferred without regard to content
> > - byte value for byte value.

No, I was wrong. Same mechanism as above.



Regards,

Ann
www.ibphoenix.com
We have answers.


From BLB_open_2 in blb.c

else if (to == BLOB_text && (from_charset != to_charset))
{
if (from_charset == CS_dynamic)
from_charset = tdbb->tdbb_attachment->att_charset;
if (to_charset == CS_dynamic)
to_charset = tdbb->tdbb_attachment->att_charset;
if ((to_charset != CS_NONE) && (from_charset != to_charset))
{
filter = (BLF) ALLOCP (type_blf);
filter->blf_filter = filter_transliterate_text;
filter_required = TRUE;
}
}

from filter.c
STATUS filter_transliterate_text (
USHORT action,
CTL control)
{
/**************************************
*
* f i l t e r _ t r a n s l i t e r a t e _ t e x t
*
**************************************
*
* Functional description
* Get next segment from a text blob.
* Convert the text from one character set to another.
...