Re: Where is stringbuilder?



J French wrote:
On Fri, 20 Oct 2006 13:36:38 +0200, "Maarten Wiltink"
<maarten@xxxxxxxxxxxxxxxxxx> wrote:
"J French" <erewhon@xxxxxxxxxx> wrote in message
news:45388471.503443109@xxxxxxxxxxxxxxxxxxx
Is there ever a case where Length( S[n] ) = 2 ?

No. A character is a character even if it's a WideChar.
SizeOf(S[n]) might, though.

Slap ! SizeOf() - would it really ?
- that would mean that a Char by Char copy of one string to another
could result in a significant crunch

No, SizeOf is a compile-time constant (with one exception having to do with open arrays). If S is an AnsiString, SizeOf will return 1 above. If S is a WideString, then SizeOf will return 2. If S is a String, then SizeOf will return 1 in Win32 and 2 in .Net.

Is it actually possible in Delphi, for the number of Bytes in a string
to be different from its Length() ?

(obviously not WideString stuff)

No.

--
Rob
.



Relevant Pages

  • Re: remove entry from text file [NOT A HOMEWORK]
    ... with sizeof: it's much more efficient. ... A string literal has type char[]. ... point to an anonymous char array containing the string literal. ...
    (comp.lang.c)
  • Re: Problem With C?
    ... Prints 1 even after copying the whole string into it ... a is a char and sizeof is a compiler time operator. ...
    (comp.lang.c)
  • Re: Q: memcpy str to struct
    ... I have a string (defined as a character array), ... comprises of unsigned chars, chars or char arrays. ... 'string' into the structure, in one action, using memcpy ... memcpy(s.a, str + start, sizeof s.a); ...
    (comp.lang.c)
  • Re: Problem With C?
    ... Prints 1 even after copying the whole string into it ... sizeof returns the size of the *type* of a, ... char, which is by definition 1 byte. ...
    (comp.lang.c)
  • SSPI Kerberos for delegation
    ... const char *tokenSource, const char *name = NULL, ... DWORD bufsiz = sizeof buf; ... int n = ib.cbBuffer; ... // wserr() displays winsock errors and aborts. ...
    (microsoft.public.dotnet.framework.remoting)