Subject | Re: [IBO] Re: Right-trimming defaults |
---|---|
Author | David Trudgett |
Post date | 2001-03-23T02:41:26Z |
At 2001-03-22 18:44 -0700, "Jason Wharton" <jwharton@...> wrote:
or lack thereof, with a grain of salt.
we're just dealing with AnsiStrings at the moment. Will future versions
have to use WideStrings for Unicode support?
I've got no problem with the exception being raised. Putting square pegs
into round holes didn't work even in kindy.
David Trudgett
>Have a look at these methods.. This should do it:I haven't looked much at the internals of IBO before, so take my comments,
or lack thereof, with a grain of salt.
>function TIB_Column.GetAsRawString: string;How do multi-byte character sets get handled? Obviously, for starters,
>var
> tmpLen: word;
>begin
> if FNewColumnInd^ = IB_NULL then
> Result := ''
> else
> case SQLType of
> SQL_Text,
> SQL_Text_:
> Result := Copy( Pchar( FNewColumnBuffer ), 1, SQLLen );
> SQL_Varying,
> SQL_Varying_: with SQL_VARCHAR( FNewColumnBuffer^ ) do
> begin
> tmpLen := vary_len_low + vary_len_high * 256;
> SetLength( Result, tmpLen );
> Move( vary_string, pchar( Result )^, tmpLen );
we're just dealing with AnsiStrings at the moment. Will future versions
have to use WideStrings for Unicode support?
> endThat looks like it will do the job.
> else
> Result := AsString;
> end;
>end;
>procedure TIB_Column.SetAsRawString( const NewValue: string );Shouldn't that be "word" also?
>var
> StrLen: smallint;
> tmpVal: string;I don't know where BestFieldName is coming from, but it sounds interesting...
>begin
> tmpVal := NewValue;
> StrLen := Length( tmpVal );
> case SQLType of
> SQL_Text,
> SQL_Text_:
> begin
> if StrLen > SQLLen then
> raise Exception.Create( 'String truncation: ' + BestFieldName );
I've got no problem with the exception being raised. Putting square pegs
into round holes didn't work even in kindy.
> SysBeforeModify;Thanks!
> FillChar( FNewColumnBuffer^, DataSize, FPadChar );
> if ( StrLen = 0 ) and FBlankIsNull then
> SysSetIsNull( true )
> else
> SysSetIsNull( false );
> Move( tmpVal[1], FNewColumnBuffer^, StrLen );
> SysAfterModify;
> end;
> SQL_Varying,
> SQL_Varying_: with SQL_VARCHAR( FNewColumnBuffer^ ) do
> begin
> if StrLen > SQLLen then
> raise Exception.Create( 'String truncation: ' + BestFieldName );
> SysBeforeModify;
> FillChar( vary_string, SQLLen, FPadChar );
> if ( StrLen = 0 ) and FBlankIsNull then
> SysSetIsNull( true )
> else
> SysSetIsNull( false );
> vary_len_low := StrLen mod 256;
> vary_len_high := StrLen div 256;
> Move( tmpVal[1], vary_string, StrLen );
> SysAfterModify;
> end
> else
> AsString := tmpVal;
> end;
>end;
David Trudgett