How to determine the ASCII code of a character ?
Displaying 1-4 of 4 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
ethereal

Hi all
There is chr function in VergeC that returns a character corresponding to the given ASCII code. But can it be done vice versa ? I'm now developping a vc-library that will give possibility to use non-english characters in the output text both with english-ones, in order to make localized text and dialogs. In other word it works with two 96-characters fonts as if we worked with one on 192-characters, including national codepage.
I almost finished, but i really lack this function :( Can anybody help ?

Posted on 2006-10-14 15:26:35 (last edited on 2006-10-14 15:28:10)

ethereal

Ok, sorry, it seems I have already found it. asc function must be what I need. I was simply looking for it in an old language reference.

Posted on 2006-10-14 15:36:37

ethereal

Yeah I've done it!!! Now it works perfectly and i can make RPG in my native language(s) :)

Btw, it seems i have found a bug in the asc function:

//****************************************
int i=asc(chr(128));
if (i==-128) MessageBox("Voilà!");
//****************************************

The situation is the same with all the characters from 128 to 255 on Windows-1251 codepage (maybe on others too, havent checked yet)

I think the problem is with forgoten unsigned in the source code of the function. They calculate first the ASCII code into a signed short and then return it as int :/

It's easy to bypass if write like that:

// asc with positive native-characters
int masc(string c_str) {
int i=asc(c_str);
if (i<0) i+=256;
return i;
}

Posted on 2006-10-14 16:25:28 (last edited on 2006-10-14 16:27:36)

mcgrue

Etherial!

If you're trying to use extended-set ASCII characters, it's probably safer for you to use the vc libraries that have already been coded for extended sets than to hack the source, since that'd mean you need to change the font handlers too.

I'm just thinking that it might be a larger endeavor than anticipated.

Posted on 2006-10-28 12:53:03


Displaying 1-4 of 4 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.