Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Korean Characters & C++ #45

Closed
Tyrannmisu opened this issue May 19, 2016 · 8 comments
Closed

Korean Characters & C++ #45

Tyrannmisu opened this issue May 19, 2016 · 8 comments

Comments

@Tyrannmisu
Copy link

Hi,

i need to write Korean Characters (example: 구결/口訣) into an Oracle database via a C++ Middleware that is using the OCILIB.
It is already possible to write and save these characters with a C# Service that uses the Oracle-Libs, which means that the Database should be configured correctly.

The C++ Middleware runs on Linux and we set the NLS_LANG to GERMAN_GERMANY.AL32UTF8.
I am able to see the characters in the console/log but if i try to write them into the database via an Object that accepts the values as parameters they turn to '¿¿¿¿'.

The C#-Service uses the same Objects to write the data.

The values are bound as strings (std::string) in the C++ Middleware.
Do i need to adjust anything else than the NLS_LANG to make this work?
For example the Binding?

I could not find anything that matters in the OCILIB C Documentation and there aren't any examples for C++ for cases with special characters.

We tried for days but the characters ultimately end up as '¿¿¿¿' in the database tables if we write them via the C++ Middleware.

Thanks for your help!

@vrogier
Copy link
Owner

vrogier commented May 27, 2016

Hi,

What version of ocilib are you using ?
What ocilib charset mode (ansi/widechar) ?
What platform ?

Regards,

Vincent

@Tyrannmisu
Copy link
Author

We are using ocilib 4.2.0 with charset mode ANSI.

The c++ Middleware runs on Red Hat Enterprise Linux Server release 6.7.
The Database is: Oracle Database 12c Enterprise Edition 12.1.0.2.0 64 bit

We found out that it works as desired without further adjustments of the middleware if the database is installed with an "AL32UTF8" Charset. (NLS_CHARACTERSET = AL32UTF8)

The other database-installation was done with "WE8ISO8859P15", this turned all korean characters to '¿¿¿¿'.

Still weird that it worked via a C# service.
My guess: The C# -Service wrote the strings as nvarchar, which is set to "AL16UTF16" in the database.

It seems like ocilib binds the values as varchar, which is set to "WE8ISO8859P15".
But that's really only me guessing.

@vrogier
Copy link
Owner

vrogier commented Jun 4, 2016

Hi,

you can use OCI_BindSetCharsetForm(bind, OCI_CSF_NATIONAL) to indicate you're binding strings using national charset) :)

Regards,

Vincent.

@Tyrannmisu
Copy link
Author

Thanks!

I'll try that :)

@vrogier
Copy link
Owner

vrogier commented Jun 23, 2016

Hi,

Any news ?

Regards,

Vincent

@Tyrannmisu
Copy link
Author

Sry that i was quiet for so long.

The problem is that i don't have an Database to test it any more.
The Only one that i can test against was re-installed with "AL32UTF8".

If i get a chance to test OCI_BindSetCharsetForm(bind, OCI_CSF_NATIONAL) against a "WE8ISO8859P15"-database i will. But right now i don't have this possibility in the current project.

We are supposed to get a new development-DB where we can play around, but i cannot change the charsets in the database we have right now.

@Ben136KBC
Copy link

FYI: We can successfully write Unicode to a database using OCILIB, using ANSI charset mode on Windows. We have this code:

     _putenv_s( "NLS_LANG", "American_America.UTF8");
     boolean ret = OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT);
     _putenv_s( "NLS_LANG", "");

And it also requires the database to have a suitable character set I think.
Any strings you transfer have to be UTF8 encoded first!

@vrogier
Copy link
Owner

vrogier commented Jan 22, 2017

Closing it as answers have been provided and no more OP activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants