Solved

pass unicode from COM client to COM server

Posted on 2004-03-24
2
276 Views
Last Modified: 2010-04-01
hello, all,

  A COM server (VC6.0) which requires a string with unicode characters from client (VC6.0), therefore I defined a BSTR variable in COM server interface. it looks like:

//COM server
CCNStServer::GeneralBrowser(BSTR name)
{
.....
}

On client side, my code looks like:
//COM Client
_bstr_t name("xxxxxxx"/*unicode might be inside of this string*/);
theApp.GetServerHandle()->GeneralBrowser(name);
...
 I found that only Ascii characters can be passed to COM server, I have no idea where  those unicode characters are!, anybody can help me?

thanx in advance
 
 
0
Comment
Question by:kim_wei
2 Comments
 
LVL 12

Expert Comment

by:andrewjb
Comment Utility
"xxxxx" isn't a unicode string literal.

You need, say

_T("xxxxxx")
0
 
LVL 23

Accepted Solution

by:
chensu earned 50 total points
Comment Utility
Though "xxxxx" is an ANSI string, the constructor of _bstr_t is able to convert it to Unicode. To explicitly specify Unicode strings, use L"xxxxx". I don't think there is a problem. How do you know the Unicode strings are not working? Maybe you are debugging it without turning on Unicode?

Check the following option,

Menu Tools/Options..., Debug tab, Display unicode strings
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now