How can I output the arrow characters using TextOut() ?
I would think this is a simple thing, but after an hour of searching Google, I haven't turned up anything. I made a snake game where the user presses the arrow keys to move the snake. I thought it would be nice to TextOut() the message: "Press the arrow keys to move the snake" and I wanted to display the 4 arrows. As I said, that was over an hour ago! It's a little thing, but it's really bugging me. Any help would be greatly appreciated.
Thanks.
Why not just write up, down, left, right? If thats not what your looking for your going to make images of each key or all keys and draw them directly to the screen.
Right. I understand there's a lot of alternatives. I guess I'm just being stubborn. Is there a unicode representation of the arrow characters?
A lot, however, it depends on your specified font. I'll take the most popular font in Windows - Arial. Take a look at character map, the arrow characters are represented in 25B2, 25BA, 25BC, 25C4 Unicode.
I also remember in original DOS code page there're arrow characters.
Btw, are ^ v < > sufficient :) ?
I also remember in original DOS code page there're arrow characters.
Btw, are ^ v < > sufficient :) ?
Very strange. I would expect the following code to print "!" to the screen, but it doesn't
Instead it prints nothing. What am I missing?
char buffer[80];sprintf(buffer,"\0x21"); // unicode for "!"int len = (int)strlen(buffer) ;int x = (WINDOW_WIDTH /2) - (len * 4);int y = WINDOW_HEIGHT/3;TextOut(hdc,x,y,buffer,len);
Instead it prints nothing. What am I missing?
Both of the following strings work in one of my programs:
tempString += L'ø';
tempString += 0xF8;
For the first, I just copied the ø character into my source code from Windows' character map. Note that the second line is a piece of data, not a string - try removing the quotes around 0x21 in your code.
tempString += L'ø';
tempString += 0xF8;
For the first, I just copied the ø character into my source code from Windows' character map. Note that the second line is a piece of data, not a string - try removing the quotes around 0x21 in your code.
I started this day feeling fairly intelligent. That feeling has long passed. The first method of copying and pasting the special character worked, but TextOut requires a const char* and 0xF8 apparently is an int. I tried various things to beat it into submission but to no avail. Could I trouble you for a more complete code example? An example printing the arrow characters would be even better.
Thanks for the responses.
Thanks for the responses.
Quote:Original post by vinb
Very strange. I would expect the following code to print "!" to the screen, but it doesn't
*** Source Snippet Removed ***
Instead it prints nothing. What am I missing?
Your escape sequence isn't correct. \0 evaluates to a NUL (character value 0), which represents the end of a string in C-style strings and C++ string literals. So the x21 is in the string, but it's interpreted as actual "x21" characters, and it's after the null terminator, so it will never appear.
The escape sequence should be \x21 - \x indicates a hex representation of a literal character value.
Aha! It works. But I fear I'm not going to be able to do what I originally set out to do, which was print the arrow characters. I would like to print \x206D (the up arrow) and I'm getting this error:
error C2022: '8301' : too big for character
Is there some conversion function that I can use to feed sprintf()?
error C2022: '8301' : too big for character
Is there some conversion function that I can use to feed sprintf()?
Unicode requires two bytes per character, unlike ASCII which uses one byte. 0x206d is larger than 0xff (255) which is the highest possible value you can store in one byte.
What you need (to print multi-byte characters, anyways) is a wide string, which means the bulk of your program will have to be modified to use Unicode. That's a bit extreme.
What you need (to print multi-byte characters, anyways) is a wide string, which means the bulk of your program will have to be modified to use Unicode. That's a bit extreme.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement