Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

wat

Name: Anonymous 2009-02-19 15:36

I compile the following code in Microsoft Visual Studio 2008:

#include <windows.h>

int WINAPI
WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, int nCmdShow)
{
    MessageBox(NULL, "Hello World", "Notes!", MB_OK);
    return 0;
}

And the output is in some crazy moon runes that I don't understand (east-asian characters), rather than the plain "Hello World" I was expecting. What gives?

Name: Anonymous 2009-02-19 15:39

You are compiling with unicode support and Windows interprets your ASCII string as an UTF-16 string.

Name: Anonymous 2009-02-19 15:41

>>2
Any idea how I get rid of said unicode support? Or perhaps, how to keep the unicode support in and change my strings to UTF-16?

Name: Anonymous 2009-02-19 15:43

L"Hello World", L"Notes!"

Name: Anonymous 2009-02-19 15:45

>>2
Oddly, the compiler should catch that particular error, though it does sound like it might be the case.

OP, What is your default system locale set to? (see "Language for non-Unicode programs" in Regional and Language options)

Name: Anonymous 2009-02-19 15:46

Awesome, thanks. Gonna have to read a bit on this I think.

Saging my own thread because it's no longer needed.

Name: Anonymous 2009-02-19 15:52

>>5
system locale is set to swedish, and swedish is used for non-unicode programs, the OS is Windows 7. I did realize it might've had something to do with unicode support after checking what the compiler was doing with my code, but I didn't understand why.

And the compiler didn't say a thing about it.

Name: Anonymous 2009-02-19 16:12

Harry Potter is a fictional story about fictional magic.
SICP is a real book about real magic.

Name: Anonymous 2009-02-19 16:16

Don't you have to define UNICODE before the win32 API gives you unicode support?

Name: Anonymous 2009-02-19 16:18

>>8
Is that even relevant to the conversation, or is it just your way of saying "I've read Harry Potter"?

Name: Anonymous 2009-02-19 16:30

>>9
I have no idea, but apparently that wasn't necessary in my case. I may have accidentally told visual studio somewhere that I wanted unicode support in projects I create myself, and it proceeded to add it in for me (in my case, all it really did was add a few lines to the compilers' commandline options).

Name: Anonymous 2009-02-19 17:55

IIRC use MessageBoxA, or something like that, and it'll work.
It's been a long time since I had the misfortune of developing on Windows, though.

Name: Anonymous 2009-02-19 18:03

>>11
why would you not want unicode support? do you like broken programs?

Name: Anonymous 2009-02-19 18:43

not using UNICODE is just st00pid because windows internally converts your multibyte strings to unicode anyway so just use unicode already.

Name: Anonymous 2009-02-19 23:59

>>13
He's an Anonix developer. He considers Unicode support bloated.

Name: Anonymous 2009-02-20 2:33

If you must code with TCHAR style, use the _T() macro

#include <windows.h>

int WINAPI
WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, int nCmdShow)
{
    MessageBox(NULL, _T("Hello World"), _T("Notes!"), MB_OK);
    return 0;
}


so your calls to the Win32 APIs are independent of Unicode vs MBCS setting.

Name: Anonymous 2009-02-20 2:40

>>15
UTF-8 is superior. Who the fuck regularly uses 2-byte characters anyway?

Name: Anonymous 2009-02-20 2:43

>>17
Japan, China

Name: Anonymous 2009-02-20 3:03

>>17
mathematicians, physicists, linguists

Name: Anonymous 2009-02-20 3:07

>>17
I regularly have to use my '\upenis', which is a 2 byte character.

Name: Anonymous 2009-02-20 4:02

ITT: Windows lusers

Name: Anonymous 2009-02-20 4:37

>>13
Unicode support is fine as long as it doesn't cause me unnecessary headaches. In this case, it caused me headaches until >>2 explained what was going on, which I am ever so grateful for.

Name: Anonymous 2009-02-20 5:25

>>22
It seems MS changed the default API type mode used by the compiler from ANSI to UNICODE/ ( It uses *W instead of *A now )
The functionality has always been available, just the default used to be ANSI.

Don't change these.
Name: Email:
Entire Thread Thread List