[cpp] for(int i = 0; i < charListSize; i++)
if(charList[i] == text[stringPos])
{
art->setTile(i + charOffset, startTile.getX() + x,
(startTile.getY() + ((size.getX() / len) - 1)) + y,
-1, -1, -1, -1, -1, -1, -1, -1);
stringPos++;
break;
}[/cpp]
[cpp] charList = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_ abcdefghijklmnopqrstuvwxyz{|}~";[/cpp]
I want to somehow cachecharList so for every letter in text I can pull a value from it.
I've tried an array using the ASCII codes for the letters, but I think I overwrited memory and that isn't a good thing to do.
I'm considering making an array with the max char code as the amount of entries and then pulling it from that, but there'd be LOADS of blank entries.
Do you good fellers have any idea how I could do this properly?
Well, you can simply put the char 32 to 126 in the array, or if you want the extended ascii-set then 128-254 as well (255 is just some empty character and 127 is DEL).
You might wanna consider Unicode, though that will be a harder task to implement.
[QUOTE=ZeekyHBomb;18814562]Well, you can simply put the char 32 to 126 in the array, or if you want the extended ascii-set then 128-254 as well (255 is just some empty character and 127 is DEL).
You might wanna consider Unicode, though that will be a harder task to implement.[/QUOTE]
I want all chars allowed in string.
ansi-string:
[cpp]std::string::value_type charList[(std::abs(std::numeric_limits<std::string::value_type>::min()) + std::abs(std::numeric_limits<std::string::value_type>::max())];
for(char c = std::numeric_limits<std::string::value_type>::min(); c != std::numeric_limits<std::string::value_type>::min(); ++c) //works due to overflow
charList[i] = c;[/cpp]
[QUOTE=Eleventeen;18814683]I want all chars allowed in string.[/QUOTE]
Well, look at the ASCII chart. Only character values between 32 and 126 have a printable character associated with them. The rest are control characters.
Sorry, you need to Log In to post a reply to this thread.