Solved

How to read Unicode data in Oracle?

Posted on 2004-04-09
9
513 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
Technology Partners: 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Suggested Courses

739 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