Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Xiachunyi

Windows: Character to Numerical Identity

This topic is 5276 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 was wondering if Windows or the C/C++ language already has definitions for character to numerical identity. For example as in virtual keys here. For this example, the hexadecimal number corresponds to the symbol/function that it indicates. Would this be implemented the same way in C/C++? Should I look at the ASCII codes and offset the virtual key codes to match what I need to print instead of having multiple if statements for each case or having a lookup table that lists numbers in the first column and the equivalent characters in another? Also if Windows or C/C++ has a table with corresponding number to character identities, how would I change the number to a character - would I use something like "(char)0x4D"? Here is part of my source code I am trying to implement in if it helps.
                if((loop >= 0x30 && loop <= 0x5A) || (loop >= 0x60 && loop <= 0x6A))
                {
                    //Convert loop contents to character or match identity then place in string buffer

                    MessageBox(NULL, "You''ve pressed a key","Test",MB_OK);
                }
Thank you.

Share this post


Link to post
Share on other sites
Advertisement
I''m not sure if I understand what you want. Do you basically want to convert a scan code to ASCII? If so, there was an article on GameDev.net covering that (and a few topics in the forum, too).

Share this post


Link to post
Share on other sites
You can use the ASCII codes to determine the identity between values and their display characters. And yes, you would cast to char to treat a value as a character. However, this only works with the ASCII set, and not anything else like Unicode.

Share this post


Link to post
Share on other sites
Thanks for the help.

I want to indeed change the virtual key code to its alpha/numeric equivalent. I thought about utilzing a 2D array that has the virtual key codes in one column and the alpha/numeric equivalent in another but seeing as I might try reinventing the wheel - I decided to see if there was already a conversion.

I''ll search on Gamedev for any articles pretaining to virtual key codes to their equivalent symbol.

Thank you Zipster, I''ll try that out.

Share this post


Link to post
Share on other sites

  • 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!