Menu

Does ocilib support GB2312 or UTF8 code?

nlpack
2009-12-02
2012-09-26
  • nlpack

    nlpack - 2009-12-02

    I had try ocilib connected Oracle10g, if the column is ansi character,it's
    ok,the program compile and execute is right,
    but is column value contain GB2312 or GBK character,the program can't exeute.
    In pl/sql view the table data
    is correct.
    if compile demo file with OCI_CHARSET_UNICODE and link program with -locilibw
    , program can execute,but get data value was wrong.
    and use OCI_CHARSET_UNICODE option, must use wchar_t for string parameter,too
    many parameter must covert string and char to wchar_t,
    it's not suitable for programer covert it everywhere.

    my environment is :
    windows 2000 professional
    MINGW32 5.1.6
    gcc 3.4.5
    ocilib 3.4.0
    Oracle 10.2.4(Database character is utf8 and use jdbc can query GB2312 string
    value)

    use ocilib demo file to compile,add OCI_API=__stdcall, OCI_CHARSET_ANSI,
    OCI_IMPORT_LINKAGE to gcc Preprocessor ,
    add ocilib\include to gcc include file path, add ociliba for gcc linker
    libraries ,add ocilib\lib32 to gcc linker
    library search path, add ocilib\lib32 to system path.

    what and how can i do, then the program can read GB2312 code character by
    ocilib?
    Someone can give me a demo and setting ?

    Thinks !

     
  • Vincent Rogier

    Vincent Rogier - 2009-12-02

    Hi,

    first, have you tried OCI_CHARSET_MIXED ?

    and what is wrong with the unicode build when you say ",but get data value
    was wrong"

    OCILIB doest not know about encoding... it just manipulate ansi string or
    UTF16 oracle oci strings data mapped to wchar_t...

    Version 4.0.0 will introduce the choice of using ansi, utf8, utf16 or utf32
    charset type.

     
  • nlpack

    nlpack - 2009-12-03

    yes, I had tried use OCI_CHARSET_MIXED ,if use this option, all function
    string parameter must use wchar_t type.
    In c++ program,we can use string object store UTF8 or GB2312 character, then
    print it does'nt covert to wchar_t.

    For another question:
    sometime use OCI_GetString(rs,col_index) or OCI_GetString(rs,col_name) occur
    some error ,how to handler it? the demo
    can't handler this error.

     
  • nlpack

    nlpack - 2009-12-03

    database application use C++ is better more then C,. I'm try use occi ,but
    it's not support gcc3.4,so i found ocilib and try it.

     
  • Vincent Rogier

    Vincent Rogier - 2009-12-03

    withh OCI_CHARSET_MIXED, only user data are wchar_t.
    Sql queries, attributes are char.

    what errors are you talking about for OCI_GetString() ?

     
  • nlpack

    nlpack - 2009-12-03

    like this:
    database table has 10 row data, sometime use OCI_GetString() get table data,
    then get eighth row occur some error ,how to handler it?

     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.