user1268935
user1268935

Reputation: 21

OCILogon failure for OCI_UTF16 enviornment

The OCILogon function says username ,password and database parameters must be in UTF-16 encoding in OCI_UTF16 environment mode. I am passing these parameters as follows,

OCILogon(p_env, p_err, &p_svc,"scott", 5,"tiger",5,"test" , 4);

Please let me know how to pass in UTF_16 format. Do I have to use OCI_ATTR_CHARSET_ID and set it to OCI_UTF16?

Upvotes: 2

Views: 743

Answers (1)

Coren
Coren

Reputation: 5637

You're right, Oracle documentation says that it :

Must be in UTF-16 encoding in OCI_UTF16 environment mode.

In order to convert it to UTF-16, they don't say it here but Oracle provides a simple macro. It should be as simple as this :

rc = OCILogon(p_env, p_err, &p_svc, UTF16("scott"), 5, UTF16("tiger"), 5, UTF16("d458_nat"), 8);

Documentation claims too that you can also use a "L" in order to use widestring literal, so this should also works :

 rc = OCILogon(p_env, p_err, &p_svc, L"scott", 5, L"tiger", 5, L"d458_nat", 8);

NB: You should include ocilib.h and link with ocilibw.Lib, as stated by oci documentation :

On Microsoft Windows, 32bits and 64bits (x86) DLLs are provided and can be easily recompiled. Unpack the current archive (ocilib-xyz-windows.zip)
Copy ocilib\include\ocilib.h
Copy ocilib\lib32 |64\ocilib [x].Lib
Copy ocilib\lib32|64\ocilib [x]. Dll [...]
Where [x] is the compiled version of OCILIB ('a'> -> ANSI, 'w' -> Unicode, 'm' -> Mixed)

Upvotes: 1

Related Questions