Public Group

# Problem with wide chars in VC++ 2005 Express

This topic is 4566 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Okay I got a new problem in Visual C++ 2005 Express. I created a win32 program and loaded my opengl template code. After templewulf and SiCrane told me how to link libs in VC++ 2005, I tried to build it and had another error. I had made a global character array called ProgramName, and I had been just inserting the name of my program in there everytime I used the template for a different program. (I know, everyone says to use strings but I'm hard headed =) ). Well, in VC++ when I tried to compile it, it gave me this error: 'CreateWindowExW' : cannot convert parameter 2 from 'char [9]' to 'LPCWSTR' Also it complained about the same thing for my message boxes. I looked around a little and finally realized that CreateWindowExW and MessageBoxW are for wide characters, not regular ones. And CreateWindowEx and MessageBox are typedefed to the FunctionNameWs if UNICODE is defined and FunctionNameA if it's not. I believe this is the source of my problems. So why and where is UNICODE defined? Because I don't want it to be. Also, as a "side question", I noticed that when I tried to use my input method editor to enter japanese characters in my old VC++ 6.0 Introductory Edition, it replaced them with questions marks. But VC++ 2005 Express doesn't. So I thought I could now use japanese characters in my programs, but when changed my ProgramName array to a WCHAR array and tried to compile it, after telling me I'd need to save my cpp file in unicode format, it gave me these errors:
------ Build started: Project: Degenetron, Configuration: Debug Win32 ------
Compiling...
Degenetron.cpp
c:\documents and settings\owner\desktop\icon folder\opengl programming stuff\degenetron\degenetron\degenetron.cpp(9) : warning C4566: character represented by universal-character-name '\u30C7' cannot be represented in the current code page (1252)
c:\documents and settings\owner\desktop\icon folder\opengl programming stuff\degenetron\degenetron\degenetron.cpp(9) : warning C4566: character represented by universal-character-name '\u30B8' cannot be represented in the current code page (1252)
c:\documents and settings\owner\desktop\icon folder\opengl programming stuff\degenetron\degenetron\degenetron.cpp(9) : warning C4566: character represented by universal-character-name '\u30A7' cannot be represented in the current code page (1252)
c:\documents and settings\owner\desktop\icon folder\opengl programming stuff\degenetron\degenetron\degenetron.cpp(9) : warning C4566: character represented by universal-character-name '\u30CD' cannot be represented in the current code page (1252)
c:\documents and settings\owner\desktop\icon folder\opengl programming stuff\degenetron\degenetron\degenetron.cpp(9) : warning C4566: character represented by universal-character-name '\u30C8' cannot be represented in the current code page (1252)
c:\documents and settings\owner\desktop\icon folder\opengl programming stuff\degenetron\degenetron\degenetron.cpp(9) : warning C4566: character represented by universal-character-name '\u30ED' cannot be represented in the current code page (1252)
c:\documents and settings\owner\desktop\icon folder\opengl programming stuff\degenetron\degenetron\degenetron.cpp(9) : warning C4566: character represented by universal-character-name '\u30F3' cannot be represented in the current code page (1252)
c:\documents and settings\owner\desktop\icon folder\opengl programming stuff\degenetron\degenetron\degenetron.cpp(9) : error C2440: 'initializing' : cannot convert from 'const char [8]' to 'WCHAR []'
There is no context in which this conversion is possible
Build log was saved at "file://c:\Documents and Settings\Owner\Desktop\Icon Folder\OpenGL Programming Stuff\Degenetron\Degenetron\Debug\BuildLog.htm"
Degenetron - 1 error(s), 7 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


What does it mean they can't be represented? They are represented. At least I can see them, and they're not replaced with question marks. At any rate, what I really want is to get the compiler back to the way it was before, with regular 8-bit characters. Help would be appreciated. Thanks in advance.

##### Share on other sites
For the first part of your problem: go to your project settings, under general, go to the character set option and change it from Unicode to Multi-Byte. That should undefine UNICODE.

##### Share on other sites
Ah, k. Thanks again =).

##### Share on other sites
For the other part, codepage 1252 is the 8 bit ANSI codepage, which obviously can not represent unicode characters (codepage 1200 for instance) that are not in it. To fix that problem, simply save the source code files to be saved as unicode files. Select the file, then go to File->Advanced Save Options and set the encoding to 1200 or someother unicode format.

##### Share on other sites
I tried File->Advanced Save Options and selected Unicode - Codepage 1200 from the encoding list. But it still gave me the same errors.

Then I try saving it in a few of the japanese ones (like "Japanese (Shift-Jis) - Codepage 932"), and it gives me this error:

error C2440: 'initializing' : cannot convert from 'const char [25]' to 'WCHAR []'

So then I change the WCHAR array to a char array and it compiles, but when I execute the program, it's not what I entered at all, just some screwed up junk.

I mean this isn't really all that important. I used to be/kind of still am interested in japanese and I learned the kana, but I don't really *know* japanese and will likely never make a program that needs to use japanese characters. But it's still kind of annoying that I can't get the program to work. So if you know any other reasons this isn't work, it would be appreciated. Thanks in advance.

##### Share on other sites
that junk is the charset default , it's used when the the app can't find the charechtar you
specfied. make sure you have fonts that support the lang your writing in .i don't really know
how many letters there is in a japanese alphabet , but if there is more that (2^8)256 , you
should have unicode enabled.so you can have more than 8-bits for each letter.

##### Share on other sites
Quote:
 Original post by K A Z Eerror C2440: 'initializing' : cannot convert from 'const char [25]' to 'WCHAR []'

yeah, i think you are defining text incorrectly...

char str[] = "ascii";
wchar_t wstr[] = L"unicode"; // <<-- NOTE: capital L infront of "

normally you use the TEXT() macro for this, ie :

TEXT("text string")

which should sort that for you.

##### Share on other sites
Ah, okay. Yeah I had the charset on multi byte. And the L is why it was complaining when I was trying to define the WCHAR array.

Thank you both. =)

1. 1
2. 2
Rutin
21
3. 3
4. 4
A4L
15
5. 5
khawk
14

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633737
• Total Posts
3013612
×