"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message news:<8r**********************@twister01.bloor.is. net.cable.rogers.com>...
I always add my own Replace and Split functions to all my Access 97
databases, so that it doesn't really become an issue.
I'm not aware of any string-specific APIs (largely because strings are
different between C and VB).
Thanks for the information. Here is a method for dealing with C/VB
strings. Apologies in advance to Steven Roman if I interpret what he
said incorrectly. The book gives a much more detailed look at what
goes on. You can use the following "trick" suggested by Steven Roman
in his book "Win32 API Programming with Visual Basic" ISBN:
1-56592-631-5:
<Begin Paraphrase>
Terminology:
BSTR - VB string (pointer to Unicode Array)
The Unicode character array that is pointed to by a BSTR must be
preceded by a 4-byte length field and terminated by a single null
2-byte character (ANSI = 0).
LPSTR - long pointer to a null-terminated ANSI character array (VC++
string)
LPWSTR - long pointer to a null-terminated Unicode character set with
no embedded nulls (VC++ string)
ABSTR - made-up term used for BSTR type character array pointing to an
ANSI array
s = StrConv(s, vbToUnicode)
APIFunctionW s
s = StrConv(s, vbFromUnicode)
"What we are doing here is compensating for the shrinking of our BSTR
to an ABSTR by expanding it first. Indeed, the first call to the
StrConv function simply takes each byte in its operand and expands it
to Unicode format. It doesn't know or care that the string is already
in Unicode format."
....
"Now, in preparation for passing the string to [APIFunctionW], VB
takes this expanded string and converts it from Unicode to ANSI, thus
returning it to its original Unicode state. At this point,
[APIFunctionW] can make sense of it and do [its function]. Once the
converting string returns from [APIFunctionW], VB "translates" the
result to Unicode, thus expanding it with embedded null characters. We
must convert the result to ANSI to remove the supererogatory padding."
....
Special care is required in the case of Windows 9x since it behaves
differently. (He goes on to explain how to handle that case also.)
<End Paraphrase>
There must be several string functions that are used by Win32 to
provide the OS with what it needs. BTW, Steven's explanation of how VB
stores strings internally helped me discover why I was having a
problem outputting pdf information in binary mode after a string was
used to store that information. Thanks Steven.
James A. Fortune