I took a closer look and I think I found the culprit on my side of things. I am using the column type SQL_VARCHAR and so I was not setting the sqllen figure to match my buffer and take into account the two bytes for the length. Thus, two bytes were possibly being mangled. Once I made the adjustment noted below in my code it began to work properly.
Here is my code: function GetDefaultCharSet( Cn: TIB_Connection; Tr: TIB_Transaction ): string; var POut_DA: PXSQLDA; nullind: smallint; tmpName: array[1..255] of byte; tmpLen: integer; tmpBytes: RawByteString; tmpDSQL: TIB_DSQL; begin Result := ''; if Assigned( cn ) and Cn.Connected then begin if not Assigned( Tr ) then Tr := Cn.SchemaCache.Transaction; tmpDSQL := TIB_DSQL.Create( cn ); try tmpDSQL.RetrieveDomainNames := false; tmpDSQL.IB_Connection := Cn; tmpDSQL.IB_Transaction := Tr; tmpDSQL.CheckTransaction( true, tmReadRecord ); GetMem( POut_DA, XSQLDA_LENGTH( 1 )); try with POut_DA^ do begin version := SQLDA_VERSION1; sqln := 1; sqld := 1; with sqlvar[ 0 ] do begin sqltype := SQL_VARYING; // I need to subtract two bytes from sqllen to make // room for the length indicator. sqllen := SizeOf( tmpName ) - 2; //!!!!!!!! sqldata := @tmpName; sqlscale := 0; sqlind := @nullind; relname_length := 0; sqlname_length := 0; aliasname_length := 0; ownname_length := 0; end; end; tmpDSQL.ExecImmed2( 'SELECT D.RDB$CHARACTER_SET_NAME ' + 'FROM RDB$DATABASE D', nil, POut_DA ); with SQL_VARCHAR( pointer( @tmpName )^ ) do begin tmpLen := vary_len_low + vary_len_high * 256; SetLength( tmpBytes, tmpLen ); Move( vary_string, tmpBytes[1], tmpLen ); end; Result := Trim( iboDecodeA( tmpBytes ) {Don't put CharSet here.} ); finally FreeMem( POut_DA ); if Assigned( Tr ) then Tr.CheckOat; end; finally tmpDSQL.Free; end; end; end; Thanks, Jason LeRoy Wharton www.ibobjects.com ------------------------------------------------------------------------------ WhatsUp Gold - Download Free Network Management Software The most intuitive, comprehensive, and cost-effective network management toolset available today. Delivers lowest initial acquisition cost and overall TCO of any competing solution. http://p.sf.net/sfu/whatsupgold-sd Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel