Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How do i convert existing Win32 MFC application to unicode ?

391 views
Skip to first unread message

singurd

unread,
Aug 17, 2009, 2:29:37 AM8/17/09
to
Good Day
First time doing this, i refered to an example unicode app source code
i have downloaded,
added _UNICODE preprocessor defination, then added _T data type
mappings...
now i am getting error LNK2001: unresolved external symbol _WinMain@16


Regards

Scot T Brennecke

unread,
Aug 17, 2009, 3:18:26 AM8/17/09
to

Are you referencing WinMain directly? Unicode apps have wWinMain (notice the 'w'). You haven't provided enough detail to fully
answer your question, I'm afraid.

Also you say "_T data type mappings", I trust you mean the things from tchar.h, right? Like _T(), LPCTSTR, etc.

Giovanni Dicanio

unread,
Aug 17, 2009, 5:02:37 AM8/17/09
to
singurd ha scritto:

To add to Scot's answer, I think that you will find Mihai's blog
"Internationalization Cookbook" to be very useful.

For example, this post:

"Visual Studio Unicode projects"
http://www.mihai-nita.net/article.php?artID=20060723a

offers you a visual guide with screenshots on how to compile Unicode
projects with VC6 and newer IDEs.

And there are other interesting posts as well, e.g.:

What is a "Unicode application"?
http://www.mihai-nita.net/article.php?artID=20060317a


HTH,
Giovanni

jjoohhnn

unread,
Aug 17, 2009, 5:15:17 AM8/17/09
to

Hi singurd,

1. Use _UNICODE, UNICODE (in case of MFC) flags for settings.
2. Use _t* family functions.
3. Use _T or TEXT macros to declare constant strings. It maps to either
ascii or unicode string based on preprocessor settings.
4. in case of dialog box based application, go to project -> settings ->
link -> output, add this wWinMainCRTStartup.
5. User WideCharToMultiByte() and MultiByteToWideChar() functions to convert
data from ascii to unicode vice versa.

Regards,
jjoohhnn.

"singurd" <sin...@yahoo.com> wrote in message
news:c569e884-e8ff-4bc2...@d4g2000yqa.googlegroups.com...

singurd

unread,
Aug 17, 2009, 6:04:02 AM8/17/09
to
On Aug 17, 5:02 pm, Giovanni Dicanio

Aha , i missed the wWinMainCRTStartup setting.. mihai article is a
dummy's guide for unicode project settings
Thanks for all the reply

Giovanni Dicanio

unread,
Aug 17, 2009, 1:23:55 PM8/17/09
to
jjoohhnn ha scritto:

> 5. User WideCharToMultiByte() and MultiByteToWideChar() functions to convert
> data from ascii to unicode vice versa.

Or, in addition, the OP might use the C<from>2<to> helper classes (like
CA2U, CA2T, CT2A, etc. ...), which hide the complexity of the
aforementioned Win32 APIs:

"ATL and MFC String Conversion Macros"
http://msdn.microsoft.com/en-us/library/87zae4a3(VS.80).aspx

Another suggestion I would add to jjoohhnn's list is to pay attention to
those parts of code that process the size of char buffers.

I mean: old ASCII-only (Unicode *un*aware) C/C++ code tended to use
sizeof() to get the count of char's in an array (like an array size);
but if this code is converted to Unicode, and TCHAR's are used instead
of char's in this upgrading process, then it is better to use the
_countof() macro instead of sizeof() to get the count of TCHAR's in the
array, because the _countof() macro will return the correct count in
both char's and wchar_t's cases (in fact, a char is 1 byte in size,
instead a wchar_t is 2 bytes; so, sizeof() == _countof() only in case of
char's arrays).

Giovanni

Matrixinline

unread,
Aug 18, 2009, 2:57:26 AM8/18/09
to

replace your winmain() to _twinmain()

Mihai N.

unread,
Aug 19, 2009, 5:01:58 AM8/19/09
to
Going beyond project settings:
http://www.mihai-nita.net/article.php?artID=tounicode
(also contains links to a great series by Michael Kaplan)


--
Mihai Nita [Microsoft MVP, Visual C++]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email

0 new messages