Jump to content
  • Advertisement
Sign in to follow this  
Harryu

String being interpretted as Unicode

This topic is 4813 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

ok, in my DrawText function, i have learnt that my string is being interpretted as Unicode. the problem with this is the only thing that is drawn is a few little squares i know that if i say: DrawText(NULL, "hello", blah blah blah then i can change it to DrawText(NULL, L"hello", blah blah blah and it will work correctly my problem is, i want to put the DrawText function inside another function, so the string that is to be printed is contained and transferred as char *String and when i am calling the DrawText function, i cannot say LString, or L String so i really don't know what to do is there a way you can tell the DrawText function not to interpret stuff as Unicode with a separate function or macro? if so, how would i call this any help would really be appreciated

Share this post


Link to post
Share on other sites
Advertisement
DrawText supports both ANSI and Unicode strings.
ID3DXFont::DrawTextA(...)
ID3DXFont::DrawTextW(...)
The string's type is LPCWSTR if UNICODE is defined, LPCTSTR otherwise.

Share this post


Link to post
Share on other sites
Use UNICODE, it's a good thing. Simply pass your strings in as wchar_t* instead of char*, or better, use std::basic_string<wchar_t>. If you really want to use char*, you can always convert to a unicode string using the API function MultiByteToWideChar.

Share this post


Link to post
Share on other sites
use LPCWSTR as the string type and pass it to yor own drawtext function, and use DrawTextW to drawtext

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!