I try this function. Do you have Visual Studio. i show you my example.

NOCaut wrote:
> 
> 
> char * unicode_to_1251(wchar_t *unicode_string)
> {
>       int err;
>       char * res;
>       int res_len = WideCharToMultiByte(
>               1251,                           // Code page
>               0,                                      // Default replacement 
> of illegal chars
>               unicode_string,         // Multibyte characters string
>               -1,                                     // Number of unicode 
> chars is not known
>               NULL,                           // No buffer yet, allocate it 
> later
>               0,                                      // No buffer
>               NULL,                           // Use system default
>               NULL                            // We are not interested 
> whether the default char was used
>               );
>       if (res_len == 0) 
>       {
>               printf("Failed to obtain required cp1251 string length\n");
>               return NULL;
>       }
>       res = (char*)calloc(sizeof(char), res_len);
>       if (res == NULL) 
>       {
>               printf("Failed to allocate cp1251 string\n");
>               return NULL;
>       }
>       err = WideCharToMultiByte(
>               1251,                           // Code page
>               0,                                      // Default replacement 
> of illegal chars
>               unicode_string,         // Multibyte characters string
>               -1,                                     // Number of unicode 
> chars is not known
>               res,                            // Output buffer
>               res_len,                        // buffer size
>               NULL,                           // Use system default
>               NULL                            // We are not interested 
> whether the default char was used
>               );
>       if (err == 0)
>       {
>               printf("Failed to convert from unicode\n");
>               free(res);
>               return NULL;
>       }
>       return res;
> }
> 

-- 
View this message in context: 
http://old.nabble.com/SQLite-%2B-unicode-tp32296232p32301058.html
Sent from the SQLite mailing list archive at Nabble.com.

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to