Solved

How to read Unicode data in Oracle?

Posted on 2004-04-09
9
510 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
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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Show shut-down message as Windows 8 shuts down. 9 90
Expand to include initial dialog with two choices. 9 76
has77  challenge 9 82
Annoying "thing" blocks my view 4 98
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

813 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

17 Experts available now in Live!

Get 1:1 Help Now