Hi,
I need to retrieve unicode values from the NVARCHAR column of the table and print on the putty terminal (final intention is to write into a file in utf8 or utf16 format ).
I tried the sample program provided in the developer guide but the wprintf or printf is not printing any characters at all on the terminal. When I do a sample C only program using unicode character in the printf is it displaying properly on the putty terminal.
I have tried search all thr the web but couldnt find any material or sample for retrieving and displaying unicode.
#include <sqlca.h>
#include <sqlucs2.h>
main()
{
...
/* Change to STRING datatype: */
EXEC ORACLE OPTION (CHAR_MAP=STRING) ;
utext ename[20] ; /* unsigned short type */
uvarchar address[50] ; /* Pro*C/C++ uvarchar type */
EXEC SQL SELECT ename, address INTO :ename, :address FROM emp;
/* ename is NULL-terminated */
wprintf(L"ENAME = %s, ADDRESS = %.*s\n", ename, address.len,
address.arr);
...
}
My Environment details:
Database: Oracle 11.1g
OS: SunOS 5.10
locale
LANG=
LC_CTYPE="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_COLLATE="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_ALL=
Database NLS parameters:
NLS_NCHAR_CHARACTERSET AL16UTF16
NLS_CHARACTERSET US7ASCI
NLS_LANGUAGE AMERICAN
The sample C program which worked is:
#include <stdio.h>
#include <locale.h>
int main()
{
if (!setlocale(LC_CTYPE, "")) {
printf("Can't set the specified locale! \n");
return 1;
}
printf("%ls\n", L"Schöne Grüße");
return 0;
}
Note: Above I used Chinese character for test.