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

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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: 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)
  • Re: A note on personal corruption as a result of using C
    ... impossible to write effective string validation routines by definition ... (Note that a string literal may contain embedded null characters; ... without resorting to abusive language. ... In practice, programmers typically use "struct" ...
    (comp.programming)