Unicode strings
Eric Pouech
pouech-eric at wanadoo.fr
Sat Oct 4 00:31:39 CDT 2003
Kevin Koltzau wrote:
> I've come upon an instance where I need to create a large lookup table of
> unicode strings, and was curious what the recommended way to handle this was.
> Using MSVC I would simply declare the string as L"Text"
>
> I only see two options currently, either declare the string as
> (const WCHAR[]){'T','e','x','t'}
> or store as non-unicode and use WideCharToMultiByte/MultiByteToWideChar as
> appropriate
>
> As this is being implemented for a unicode-only function, it seems silly to
> convert the string, but declaring it as (const WCHAR[]){'T','e','x','t'} is a
> little unwieldy for the quantity of data that I need to declare
>
>
>
as the L"Text" construct is not supported inside,
as using WideCharToMultiByte will cause memory and CPU consumption
(especially for static lookup tables),
the (const WCHAR[]){'T','e','x','t'} (don't forget the trailing '\0') is
the preferred. We all know it's a PITA, but it's better to put the
constraint once, at code writing time.
When I'm faced with this, I'm using some macros in emacs to do the task
(ie, from a "text" string convert it to the 't','e','x','t' form)
A+
--
Eric Pouech
More information about the wine-devel
mailing list