Re: Japanese strings get mangled when sent from VB6 to VC++ dll



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






.



Relevant Pages

  • Re: WideCharToMultiByte returns default character when input language for non-Unicode programs s
    ... I have support for Japanese installed on my machine. ... WideCharToMultiByte to translate a Unicode string to Multibyte and ... if I set the language for non-Unicode programs to English ... by examining the numerical value of the characters in the text string? ...
    (microsoft.public.win32.programmer.gdi)
  • Re: How to convert Infix notation to postfix notation
    ... If this is for an error message, why isn't it using stderr for its output? ... array of 15 characters, and you call this function with the limit 15 on ... Making sure that the only string I allocate and append to, ... because mulFactor in all versions must needs incorporate the functions ...
    (comp.lang.c)
  • Re: Prothon should not borrow Python strings!
    ... """It does not make sense to have a string without knowing what encoding ... same cul de sac as Python. ... Prothon_String_As_ASCII // raises error if there are high characters ... Python's split between byte strings and Unicode strings is ...
    (comp.lang.python)
  • Re: Letter to US Sen. Byron Dorgan re unpaid overtime
    ... put them in stupid places. ... Programming is difficult (as you must surely appreciate, ... > strings will be in the range 1...1000 characters. ... impose an artificially small limit on string length." ...
    (comp.programming)
  • Re: Byte Array to String
    ... retrieved text will mismatch the original characters. ... encoding the characters. ... Dim strFileData as String ...
    (microsoft.public.dotnet.framework.aspnet)

Quantcast