[omniORB] wstring handling in omniORB4

Thomas Amsler tpamsler@ucdavis.edu
Thu Jun 6 21:36:01 2002


Part of the application I am writing has a client/server chat module. 
All the chat messages are logged in a PostgreSQL DB.  The chat messages 
are in UNICODE, wstrings.  I am having problems with  handling the 
wstring holding the chat message during the process where the server 
should insert the chat message into the DB.  In the non UNICODE version, 
I just composed the DB insertion string and everything worked fine. In 
the UNICODE version, I cannot just compose the query string because I 
would have to compose a string consisting of char*s and CORBA:WChar*s. I 
can only pass query strings of type char* to the DB module. So the 
question is, how can I convert the data from a CORBA::WChar* string in 
to a regular char* string so that I can form a DB query string.

eg.
CORBA::String_var l_trans;
l_trans = UTIL::comp_string(INS_CHAT_LOG_TEAM,
                                   (char *)l_chat_id,
                                   "','",
                            >>> a_chat_msg,  <<<
                                   "','",
                                   a_user_id,
                                   "','",
                                   (char *)l_class_id,
                                   "','",
                                   (char *)l_team_id,
                                   "','",
                                   (char *)l_per,
                                   "','",
                                   "now",
                                   "','",
                                   RCT_VERSION,
                                   "');",
                                   END);
l_db_server->exec_db_insert(l_trans);

The comp_string() function takes any number of char* ,strings, and 
composes one string out of them.  This means that "a_chat_msg" which is 
of type CORBA::WChar* needs to be "converted" to char*.


Thank you.

-- 
Thomas Amsler
amsler@cs.ucdavis.edu
http://davinci.cs.ucdavis.edu/thomas

"Imagination is more important than knowledge."
	--Albert Einstein