Byte swapping problem with TextField using API

Matthew Jew mjew at icnc.com
Thu Jul 3 04:17:24 CDT 2008


On Jul 3, 2008, at 1:42 AM, Ruslan Zasukhin wrote:

> On 7/3/08 9:09 AM, "Matthew Jew" <mjew at icnc.com> wrote:
>
>> I was told that since I was accessing the data as a blob, that I  
>> would
>> not gain byte-swapping as needed.
>> So, I changed to this:
>>
>> Const_I_Value_Ptr myStringValue = aHTMLTemplateTable->valueText-
>>> get_Value();
>
> ValueText this is a field, yes?
>
> Try please
>
>    valueText->get_Value()->get_String( pBuffer, BufferLen );
>
> This is analog of e..g REALBasic code as
>
>    s = fldText->GetString()
>
>
> Exists 3 forms
>
>    // ---------------------
>    // get string:
>
>                            /** Get a string representation of value
> (Unicode).
>                                @param inLimit - limit of string size  
> in
> characters. */
> virtual String                get_String( tslen inLimit = -1 ) const  
> = 0;
>
>
>                            /** Get a string representation of value
> (ASCII).
>                                @param outString - Buffer for string
> representation of value.
>                                @param inBufferChars - size of buffer  
> in
> characters. */
> virtual char*                get_String(
>                                char*     outString,
>                                tslen     inBufferChars ) const = 0;
>
>                            /** Get a string representation of value
> (Unicode).
>                                @param outString - Buffer for string
> representation of value.
>                                @param inBufferChars - size of buffer  
> in
> characters. */
> virtual UChar*                get_String(
>                                UChar*     outString,
>                                tslen     inBufferChars = -1 ) const  
> = 0;
>
>
>
> -- 
> Best regards,
>
> Ruslan Zasukhin

Ruslan,

Thanks for the quick response.

I figured out how to do it.

I_FldBlob_Ptr pBlobField = QI( aBoilerplateTable->valueText,  
I_FldBlob );
unsigned long dataLength = pBlobField->get_DataSize();
NSMutableData  *aMutableData = [[NSMutableData alloc]  
initWithLength:dataLength];

Const_I_Value_Ptr myStringValue = aBoilerplateTable->valueText- 
 >get_Value();
unsigned long myStringLength = myStringValue->get_Length();
myStringValue->get_String( (UChar *) [aMutableData mutableBytes],  
dataLength );
					
returnValue = [NSString stringWithCharacters: (const unichar *)  
[aMutableData mutableBytes] length:myStringLength ];
[aMutableData release];

The get_String helps, and also it was important for me to remember that
dataLength != myStringLength, so we need to retrieve both values.

- Matthew






More information about the Valentina mailing list