Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2007
    Posts
    5

    Thumbs up Unanswered: MS SQL server handling unicode data

    Hi,

    I want to fetch Unicode data from MS SQL server 2005.I have created one user with russian language characters.

    Following is my code snippet:
    ------------------------------------
    wchar_t wchar1[55];
    char VALUE[255];

    while (rc != SQL_NO_DATA)
    {
    rc = SQLFetch(hstmt);
    if (rc != SQL_NO_DATA)
    memset(VALUE,0,255);
    int length=wcstombs( NULL,(wchar_t *)&wchar1, wcslen(wchar1));
    char* strChar = (char *) malloc((length +1 )* sizeof(char));
    if (strChar != NULL)
    {
    count++;
    memset(strChar,0, length + 1 );
    int i =wcstombs(strChar, wchar1, wcslen(wchar1) );
    printf( "i is %d\n",i);
    }
    printf( "The length is %d\n",length);
    wprintf(L"\n <%s>", wchar1);
    printf("\n simple char <%s>", strChar);
    wprintf(L"\n simple char <%S>", wchar1);
    }


    -----------------------------------

    CAn anybody help me ?
    I think problem is in fetching of name.
    Does anybody have working code for fetching unicode data from SQL server 2005.

    Also I want query that will tell the locale setting of the server and also client?


    Thanks-----

  2. #2
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    the sql server datatypes nchar/nvarchar/ntext are for unicode strings.

    if you are using char/varchar/text in your columns, they won't be unicode.

  3. #3
    Join Date
    Feb 2007
    Posts
    5

    Thumbs down HI Jezemine

    I know that nchar,nvarchar dayta types are unicode datatypes.
    But C compiler is not able to resolve them.
    It gives me error unkhown identifier.
    Do u know which header files to be added for datatype nchar?
    If you have any program for fetching unicode data,Please can you sned to me.
    Its urgent.
    I will be very thankful to you...

  4. #4
    Join Date
    May 2005
    Posts
    48
    Use the T-SQL COLLATE function and supply the corresponding collation for Russian.

  5. #5
    Join Date
    Feb 2007
    Posts
    5

    Red face Hello

    My problem is different.Actaully i want to support internationalization in my product which means product should support all the languages.
    My product is for user and password management for MS SQL server 2005.
    I want to fetch userdata in all languages.Not only in English(ANSI)
    SO every time i will niether be aware of the collation setting of the database nor the locale setting when user is created.(language in which user has been created)
    So in this situation I need generalise solution.
    for example:
    -------------------------------------------
    In Oracle using OCCI,we can set environment to OCCIUTF8.
    Code for this is
    Environment *env = Environment::createEnvironment(“OCCIUTF8”,”OCCIUTF 8”);
    {
    Connection *conn = env->createConnection(userName, password,
    connectString);

    This will work irrespective of NLS setting of server.

    -------------------------------------------

    IN the same way is there any environmenet setting which needs to be done for supporting internationalisation?

    I hope this will explain you all my realy problem.
    Please help me.....
    I am using ODBC API for this.
    If possible if anybody is having working code in c ...........
    that will be very helpful


    waiting for your help....

    Regards
    Sam

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •