Solved

How to read Unicode data in Oracle?

Posted on 2004-04-09
9
515 Views
Last Modified: 2013-11-20
Hi,

Does anyone know how to read Unicode data in Oracle database and write onto a text file? Because when I read it, some Unicode charaters change to "¿".

My code is:

void CMyDlg::ReadUnicode()
{
   _RecordsetPtr recordset = NULL;
   _CommandPtr command = NULL;
    _variant_t vRowsAffected;
    _variant_t vNull;
    vNull.vt = VT_ERROR;
    vNull.scode = DISP_E_PARAMNOTFOUND;
    HRESULT hr;
    hr = recordset.CreateInstance(__uuidof(Recordset));
    hr = command.CreateInstance(__uuidof(Command));

    command->ActiveConnection = GetConnection();
    command->CommandType      = adCmdText;
    command->CommandText      = "SELECT TEXT FROM UNICODE WHERE ID=1";

    recordset = command->Execute(&vRowsAffected, &vNull, adCmdText);

    if (recordset!=NULL)
    {
      recordset->MoveFirst();
      while (!recordset->adoEOF)
      {
             _variant_t vcode = recordset->Fields->GetItem(L"TEXT")->GetValue();
          recordset->MoveNext();
      }
    }
    recordset->Close();
    command->Release();
}

I have a string "đăng" stored in Oracle database and it displays in memory when I view it: "00142BBC  BF 00 BF 00 6E 00 67  ¿.¿.n.g".

Please help,
Thanks
0
Comment
Question by:regzero
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 12

Expert Comment

by:migel
ID: 10790406
Hi!
It seems like you put no UNICODE string into the database - Your data looks like you make it by
WCHAR* wch = L"uung";
where 'u' char is the locale specific char (not ASCII 127).
Can you fisrtly put proper unicode string into the base and test?
To make unicode string use MultiByteToWideChar API
0
 

Author Comment

by:regzero
ID: 10803356
I insert value from web using JSP. I set request.setCharacterEncoding("UTF-8").

For unicode characters with 0x00XX, e.g: "ê"->0x00EA, value is OK.
Ex, I have a string like this "lê lá là" in DB, and on the memory it shows:
001422E4  6C 00 EA 00 20 00 6C  l.ê. .l
001422EB  00 E1 00 20 00 6C 00  .á. .l.
001422F2  E0 00 00 00 00 00 02  à......

but with unicode value like 0xXXXX, e.g: "ạ"->0x1EA1, it's wrong. It converts value to "¿" ->0x00BF.
0
 

Author Comment

by:regzero
ID: 10856257
:) It's OK now, I solved it
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

Expert Comment

by:migel
ID: 10857088
Hi!
Can you place here your solution ???? just for learning?
0
 

Author Comment

by:regzero
ID: 10926444
Hi Migel,
I didn't know you posted.

I found the document in Oracle page, it's all here:

http://otn.oracle.com/products/oracle8i/htdocs/OTN_ODBC_Unicode_cabaird.htm

Dang
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 12049849
PAQed, with points refunded (300)

Computer101
E-E Admin
0
 
LVL 7

Expert Comment

by:Nievergelt
ID: 12749483
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

695 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