开发者

unable to insert ascii characters above 128 to oracle database using c++ program

I'm trying to insert characters above ascii range 128 using a C++ program(characters are Ø, Å). It's working fine for ascii characters less than 128

Data type used in database is VARCHAR2

Those characters are inserted as question marks (????) to DB If I set field value in DB with those characters through Toad and try to read using application they were read as question marks(????)

Can someone please give me an example code to how to insert strings which contains those characters(ascii value above 128)开发者_如何学Python.

I think problem with data type conversion. (Because in application level before insert to DB those characters display correctly.Also If I set field value through Toad and read from DB they are read as Question Marks. I can set field value in DB means DB column can hold those characters)

I'm using following to Define and Bind methods in my application

OCIDefineByPos(p_sql, &p_dfn, p_DBCon->p_err, iPos, (dvoid*)p->un_DataArray.pzValue, (sword)iSize, SQLT_STR, (dvoid*)p->un_FlagArray.pssValue, 0, 0, OCI_DEFAULT);

OCIBindByName(p_sql, &p_bnd, p_DBCon->p_err, (text *) zName, -1, (dvoid *) zValue, iSize, SQLT_STR, 0, 0, 0, 0, 0, OCI_DEFAULT);

Can someone help me Or If you have some sample program that can insert ascii values up to 256 please share it with me


WE8MSWIN1252 correspond to "MS Windows Code Page 1252 8-bit West European". You have to convert your strings to the Windows Code Page 1252 before inserting them in the db.

For instance, on Windows, if your strings are in utf8 then convert them to utf16 with MultiByteToWideChar and then back to CodePage1252 using WideCharToMultiByte


This may be because, there ARE no ascii characters above 128. ASCII is a 7-bit encoding.

In order to add non-ascii characters (there are no Ø, Å in ASCII), you'll need to use a different encoding to put them in. Most sane applications nowadays use utf8.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜