Re: Japanese strings get mangled when sent from VB6 to VC++ dll
- From: "Robert Morley" <rmorley@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 26 Jul 2007 17:54:36 -0400
Yeah, looks like Tony knows way more about C than I do, so I'm not surprised
I was wrong. Apparently I wasn't paying close enough attention to the
Japanese characters, as I only noticed two of the rectangles and none of the
character change, surprisingly. (While I don't read Japanese, I did skim
them for changes...just WAY too quickly, apparently. Bad
some-time-linguist, BAD! <g>)
Good luck!
Rob
"deveasy" <deveasy@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:3D2BDD2C-68A8-42AC-841F-0ECB96095BF3@xxxxxxxxxxxxxxxx
Thank you for taking a stab at this.
Note that in the first string, the 2nd and 6th characters are wrong (we
get
a rectangle). In the second string, the first three characters are wrong.
The first character comes up a rectangle, while the second and third
characters are incorrect.
??????
??????
2nd and 6th characters are wrong
????
????
Characters 1-3 are wrong
I tried padding the string with vbNullChar as you suggested, but got the
same result.
"Robert Morley" wrote:
I'm no expert on C, but is TCHAR a null-terminated data type? Maybe you
need to add null's to your string before passing it. If I recall
correctly,
BSTR is the equivalent of a VB string, but I may be pointing you in the
wrong direction. Anyway, try padding your string with a couple of
vbNullChar characters and see if that fixes the problem. Not sure why
that
would affect the leading character in one string and the trailing
character
in another, but it never hurts to give it a shot and see what happens.
Rob
"deveasy" <deveasy@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:5B9B099F-68FB-4124-A809-B6A8D96473E8@xxxxxxxxxxxxxxxx
My VB6 program sends some strings to a VC++ dll. The program works
fine
for
English, German et al. But it has problems with *some* Japanese
characters.
Please see two examples below:
Strings input from VB
??????
????
Strings obtained by C++ dll
??????
????
Here is the listing of the VB and C++ code. I'd appreciate any
pointers
to
fix this problem.
Thanks,
V.
VB code:
Declare Function DoStuff Lib "Test.dll" (ByVal strName As String) As
Double
Public Function SendToDll(strName As String) As Double
SendToDll = DoStuff(StrConv(strName, vbUnicode))
End Function
C++ code:
Declaration:
double __stdcall DoStuff(TCHAR* name);
Definition:
double __stdcall DoStuff(TCHAR* name)
{
AfxMessageBox(name);
return 1;
}
In the def file, the DoStuff function is exported
.
- References:
- Re: Japanese strings get mangled when sent from VB6 to VC++ dll
- From: Robert Morley
- Re: Japanese strings get mangled when sent from VB6 to VC++ dll
- From: deveasy
- Re: Japanese strings get mangled when sent from VB6 to VC++ dll
- Prev by Date: Re: Package and deploy
- Next by Date: Re: Strange problem with PDW
- Previous by thread: Re: Japanese strings get mangled when sent from VB6 to VC++ dll
- Next by thread: Re: Japanese strings get mangled when sent from VB6 to VC++ dll
- Index(es):
Relevant Pages
|