Default maximal length for VarChar Re: VChar vs VText

Ed Kleban Ed at Kleban.com
Thu Dec 8 00:03:02 CST 2005




On 12/7/05 11:56 PM, "Ed Kleban" <Ed at Kleban.com> wrote:

> 
> 
> 
> On 12/7/05 11:41 PM, "Ed Kleban" <Ed at Kleban.com> wrote:
> 
>> 
>> 
>> 
>> On 11/28/05 5:59 AM, "Ruslan Zasukhin" <sunshine at public.kherson.ua> wrote:
>> 
>>> On 11/28/05 3:57 AM, "Ed Kleban" <Ed at Kleban.com> wrote:
>>> 
>>>>> Actually in v2 for UTF8 the best size of VarChar will be 2044.
>>>>> 
>>>> 
>>>> Why?  Does this have to do with the natural page size of MacOS X or
>>>> something?  
>>> 
>>> Yes. Best size of page is 4K
>>> 
>>> We assume that page should keep at least 2 records.
>>> 
>>> So max size *in bytes* for one record is (4K - header) / 2 = 2044
>>>   
>> 
>> Ok,... but If I recall correctly, UTF8 does not work yet in V4RB 2.xx
>> correct?   
>> 
>> Is this true?  What bad things happen if I set db.StorageEncoding = UTF-8
>> (whatever the correct syntax for that is)?
>> 
>> If I must use UTF16 as my StorageEncoding, however I plan to use just simple
>> ASCII 8-bit character strings in RB, then presumably I should declare my
>> VarChar fields as VarChar( 1022 ) even though the test I am using in RB to
>> determine if a string will fit is "LenB( aString ) <= 2044"
>> 
>> Is this correct?
>> 
>> Will Valentina be able to store strings in UTF-8 in the future?
>> 
>> Thanks!
>> --Ed 
> 
> Actually, I think I got that backwards.  Also if the size *in bytes* for one
> record is 2044, and 4 bytes of the record are required for string size, then I
> guess I should declare:
>     VarChar( 2020 )
> and do a check in RB for:
>     "LenB( aString ) <= 1010"
> Correct?
> 

Doh!  I got it wrong again.  I'm really tired.  Ok, one last time:

4096 - (8 + 4 + 4 )  =  4096 - 16 = 4080
Therefore the field declaration should be:
    VarChar( 2040 )
And the RB test should be:
    LenB( aString ) <= 1020
Correct?

That's it.  I'm going to bed.  Nite!
--Ed




More information about the Valentina mailing list