7 Replies - 481 Views - Last Post: 06 August 2011 - 09:40 AM Rate Topic: -----

#1 juryben  Icon User is offline

  • D.I.C Head

Reputation: -3
  • View blog
  • Posts: 74
  • Joined: 30-November 10

If I use ANSI Functions but Compile Unicode is my project still Unicod

Posted 09 July 2011 - 01:01 PM

If I use ANSI Functions but Compile Unicode is my project still Unicode?

Let's say I use GetComputerNameA instead of GetComputerName and compile my project as Unicode. Will it still work on Asian OSes?
Is This A Good Question/Topic? 0
  • +

Replies To: If I use ANSI Functions but Compile Unicode is my project still Unicod

#2 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2247
  • View blog
  • Posts: 9,237
  • Joined: 18-February 07

Re: If I use ANSI Functions but Compile Unicode is my project still Unicod

Posted 09 July 2011 - 01:03 PM

Well I have not tested this but my bet would be no.
Was This Post Helpful? 1
  • +
  • -

#3 juryben  Icon User is offline

  • D.I.C Head

Reputation: -3
  • View blog
  • Posts: 74
  • Joined: 30-November 10

Re: If I use ANSI Functions but Compile Unicode is my project still Unicod

Posted 06 August 2011 - 08:32 AM

View PostNickDMax, on 09 July 2011 - 01:03 PM, said:

Well I have not tested this but my bet would be no.

I'm still wondering :/

I would think my code would be unicode since I compiled as unicode.
Was This Post Helpful? 0
  • +
  • -

#4 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: If I use ANSI Functions but Compile Unicode is my project still Unicod

Posted 06 August 2011 - 08:40 AM

What do you think ANSI vs Unicode means when compiling?
Was This Post Helpful? 0
  • +
  • -

#5 juryben  Icon User is offline

  • D.I.C Head

Reputation: -3
  • View blog
  • Posts: 74
  • Joined: 30-November 10

Re: If I use ANSI Functions but Compile Unicode is my project still Unicod

Posted 06 August 2011 - 08:42 AM

View PostOler1s, on 06 August 2011 - 08:40 AM, said:

What do you think ANSI vs Unicode means when compiling?

Unicode supports complex characters so your soft works on foreign computers.
Was This Post Helpful? 0
  • +
  • -

#6 PlasticineGuy  Icon User is offline

  • mov dword[esp+eax],0
  • member icon

Reputation: 281
  • View blog
  • Posts: 1,436
  • Joined: 03-January 10

Re: If I use ANSI Functions but Compile Unicode is my project still Unicod

Posted 06 August 2011 - 08:43 AM

He's not asking what Unicode is, rather what the compiler setting means.

The answer I would say is yes, but it would not display Asian characters.

Edit: MessageBoxW works when compiled as ASCII.

This post has been edited by PlasticineGuy: 06 August 2011 - 08:45 AM

Was This Post Helpful? 0
  • +
  • -

#7 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: If I use ANSI Functions but Compile Unicode is my project still Unicod

Posted 06 August 2011 - 08:52 AM

OK, people need to do some significant reading about Unicode.

Start with Joel Spolsky's article on Unicode.

Then search for MSDN topics on Unicode and MBCS .
Was This Post Helpful? 1
  • +
  • -

#8 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2247
  • View blog
  • Posts: 9,237
  • Joined: 18-February 07

Re: If I use ANSI Functions but Compile Unicode is my project still Unicod

Posted 06 August 2011 - 09:40 AM

Unicode in windows uses wide characters. that is it uses 16 bit values not 8bit ones. So for example if you define UNICODE before you #include windows.h and then write a line like:

MessageBoxA(NULL, TEXT("This is test"), TEXT("Did this display properly?"), MB_YESNO);

you will get an error because the TEXT macro ensures that "This is a test" is made into L"This is a test" and so the call will result in an error saying that there is no conversion from const wchar_t[13] to LPCSTR

However if you avoid using the TEXT macro and just call the ASCII version of the function with ascii strings then everything will be fine:


MessageBoxA(NULL, "This is test", "Did this display properly?", MB_YESNO);

The above will compile just fine if UNICODE is enabled or not.

Now if you try to force an ascii method to use a unicode string you will get really odd runtime errors:

MessageBoxA(NULL, (const char*)TEXT("This is test"), "Did this display properly?", MB_YESNO);

This works... but only displays T in the message box. because the wide char T is { 0x54 0x00 }

So I don't really know what you mean by " is my project still Unicode?"

Quote

I use GetComputerNameA instead of GetComputerName and compile my project as Unicode. Will it still work on Asian OSes?


If you properly called the GetComputerNameA then it would work on any windows OS that had that function available in its API. I have no idea of Asian versions of windows have the ascii versions of functions available but I would imagine so... so sure. the program will work so long as you properly called the function.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1