Solved

How to read Unicode data in Oracle?

Posted on 2004-04-09
9
507 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
Comment Utility
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
Comment Utility
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
Comment Utility
:) It's OK now, I solved it
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 12

Expert Comment

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

Author Comment

by:regzero
Comment Utility
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
Comment Utility
PAQed, with points refunded (300)

Computer101
E-E Admin
0
 
LVL 7

Expert Comment

by:Nievergelt
Comment Utility
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Running shell command from Access 3 63
sumNumber challenge 16 98
matchUp  challenge 6 48
changeXy challenge 13 56
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: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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 video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 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

14 Experts available now in Live!

Get 1:1 Help Now