Jump to content
  • Advertisement
Sign in to follow this  

WCHAR problems...

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I'm having some problems using WCHARs. In order to get them to work I seem to have to put a capital L infront of the file location so instead of WCHAR* mySound = "Sounds\\mySound.wav" I need to write WCHAR* mySound = L"Sounds\\mySound.wav" Does anybody know why this is? Also, it gets a bit fiddly when I try to retrieve this location. Like, for example, in a "radio" object, if I set the sound like: radio->setSound(L"Sounds\\mySound.wav"); I cant seem to get the same thing back when I use the relevent get function (radio->getSound()) I think this might be because somewhere during the get and set functions, I've lost the capital L. If anyone has any insight into this I'd be very grateful!! Cheers, Leon

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by RockyRacoon
WCHAR* mySound = "Sounds\\mySound.wav"

I need to write

WCHAR* mySound = L"Sounds\\mySound.wav"

Does anybody know why this is?



This is because in a char array the size of a character is 1 Byte, but with WCHAR arrays a letter is a WideCHAR and the size of every char is 2 bytes.L tellls the compiler that it is a WCHAR array.

To convert from and to WideChar try to use MultiByteToWideChar and WideCharToMultiByte functions if you're using C/C++. Using CP_OEM as codepage may work for you.

Hope this helps you

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!