Problem with Unicode Strings

From: Andr Hartmann <>
Date: Tue, 15 Apr 2008 15:04:53 +0200
Message-ID: <4804a7f6$0$4764$>

  I am having trouble with stuffing in an getting out unicode strings into/from my database. I will briefly describe what I am doing, hoping that someone can point me to a mistake and end my weeks of trying...

  • Oracle 9i client and server, connecting via OCI from a C++ (MS Dev Studio 2005) application
  • Client OS: German Windows XP, SP2
  • Server: Oracle9.2.0.1 Enterprise on Windows XP SP2, NLS_LANGUAGE=AMERICAN
  • Server character set (determined via "select value from nls_database_parameters where parameter='NLS_CHARACTERSET';"): WE8MSWIN1252
  • Client character set GERMAN_GERMANY.WE8MSWIN1252 (determined via "sqlplus /nolog" and @.[%NLS_LANG%])

  What I am doing in my program to stuff unicode in is this:

std::wstring strUnicode(L"b穾??df??");//not correctly displayed here because this message is not unicode
wchar_t* pValue = (pWS_ == NULL) ? NULL : _wcsdup( strUnicode.c_str() ); size_t nSize = (pValue == NULL) ? 0 : (sizeof(wchar_t) * (1 + wcslen(pValue)));
swdReturnCode = OCIBindByPos (
(OCIStmt*) m_pOCIStatement,
(OCIBind**) &pBindHandle,
(OCIError*) m_pConnection->_getOCIError(),
(ub4) columnIndex_,
(dvoid*) pValue,
(sb4) nSize,
(ub2) SQLT_STR,
(dvoid*) NULL,
(ub2*) NULL,
(ub2*) NULL,
(ub4) NULL,
(ub4*) NULL,

ub2 csid = OCI_UTF16ID;
swdReturnCode = OCIAttrSet(
(void *) pBindHandle

, (void *) &csid
, (ub4) 0
, m_pConnection->_getOCIError()


  The string that I am stuffing in corresponds to the following sequence of integers in my program's main memory:


  When I select I get the following back (displayed as "b穾df"):


  So it turns out that some characters have been transformed to be upsode-down question marks. I see the same thing when I dont fetch with my application but with the Oracle Enterprose Manager.

  What is wrong here? Am I missing out some important conversion on the way? Thanks in advance,
:) Received on Tue Apr 15 2008 - 08:04:53 CDT

Original text of this message