[unixODBC-support] Unicode and Wide Char strings

Neha Avasthy neha.avasthy at gmail.com
Tue Oct 19 11:20:10 BST 2010


Thanks Nick.

The code that I have has numerous such assignments to TCHAR using the _T
macro

#define _T(x) __T(x)
#define __T(x) L##x

I want to try something that requires minimal changes in the source code and
that can be altered at the macro level only for ex.

#define _T(x) __T(x)
#define __T(x) Copy_to_Unicode (x)

But not sure how this function Copy_to_Unicode will look like . Is it
something like mbstowcs () calls.

Thanks
-Neha


On Tue, Oct 19, 2010 at 3:36 PM, Nick Gorham <nick at lurcher.org> wrote:

> Neha Avasthy wrote:
>
>> To add to this , In the example below
>>
>> _T("SELECT NULL FROM DUAL"); expands to
>> L"SELECT NULL FROM DUAL";
>>
>> Thanks
>> -Neha
>>
>>  Its not much help, as I think you are stuck not using the L format, I
> normally use functional assignment.
>
> TCHAR str[ 100 ];
>
> copy_to_ucode( str, sizeof( str ), "SELECT NULL FROM DUAL" );
>
> Where copy_to_unicode is written to do the right thing.
>
> If you wanted, you could probably do something more complex using alloca(),
> making copy_to_unicode return the address of the passed memory address.
>
> #define _T(x)      ( copy_to_unicode( alloca( strlen((x)) + 1),
>  strlen((x)) + 1,  (x)))
>
> --
> Nick
> _______________________________________________
> unixODBC-support mailing list
> unixODBC-support at mailman.unixodbc.org
> http://mailman.unixodbc.org/mailman/listinfo/unixodbc-support
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.unixodbc.org/pipermail/unixodbc-support/attachments/20101019/3c3953ca/attachment.html>


More information about the unixODBC-support mailing list