I know roughly how text works on a computer - it''s been a long time since I had that lesson in school! Each character is placed by a number, I can''t remember the exact codes but e.g. A=1, B=2, C=3 etc. It''s called the ASCII character set, and I think there are also other character sets. For most languages, 256 characters are enough, so each charcter can be fitted into one byte. I beleive that some languages require alot of characters and so may require 2 bytes per character.
Now for the problem: if I am sending the letter "a" over a network (or the internet) using DirectPlay8, and the other computer uses a different language (such as English-Chinese or even the difference between U.S. and U.K english for example), is the receiving computer going to get an "a"?
The reason I ask this is because I''m writing a multiplayer game and after my first attempt, I sent a "p" to show that the used had changed position, "j" for jump, "s" for shoot etc. Now I realise it would be better coding style, and perhaps allow my game to work in different languages, to use an enumeration and used 1=move, 2=jump, 3=shoot etc. Once again another case where I should have planned in advance a little better! The only thing is that I''ve realised that it''s quite a large task to make this change, and I''m wondering if it''s worth all the bother. So, as my game stands, is it compatible to work in BETWEEN different languages?
I did notice once, that after re-installing Windows, notepad would sometimes show different characters from the ones I pressed on my keyboard. After checking some setting in the Control Panel, I realise I had my keyboard to U.S. English rather than U.K. (where I am). So I do know there are some sutble differences (although keyboards may be a different issue)
If it''s relevant, I''m using VB and that means I''m using the Chr() and Asc() functions where appropriate.
(I know this problem is more general programming than network related, but I think networking experts are most likely to know the answer because they may have come across this problem. So that''s why I chose this forum)
Thanks for any help you can give!
A letter isn''t a letter until it''s printed on the screen. Until then it''s just a number. Treat all your messages as a series of numbers. Intead of ''j'' for jump it should be 1 for jump.
And no, I don''t believe you need to worry about "hello world" turning into "hello kitty" when going from the US to Japan.
Ben
IcarusIndie.com [ The Rabbit Hole | The Labyrinth | DevZone | Gang Wars | The Wall | Hosting ]
And no, I don''t believe you need to worry about "hello world" turning into "hello kitty" when going from the US to Japan.
Ben
IcarusIndie.com [ The Rabbit Hole | The Labyrinth | DevZone | Gang Wars | The Wall | Hosting ]
Thanks Ben, for your answer, although I still don''t fully understand everything.
Yes, I do realise that''s the way foward. I do intend to change my code to use numbers instead, and then I''m quite sure it will work as intended. I am still curious whether the letter system would work or not, and the knowledge I gain from the answer may be relevant and useful.
Yes, I know that a letter is really a number until you print it - but I''m not so sure that''s true in Visual Basic. Because, to convert between a letter and number or vice versa, you must use the Asc() and Chr() functions. I would imagine that these functions involve the character set and language installed on your system. Therefore the functions may act differently on different computers, giving me the wrong results.
Since we can all read the internet and HTML pages with our web browsers from anywhere in the world, and "hello world" does not change to "hello kitty", it leads me to think that it doesn''t matter which language the user has. But using Internet Explorer 6, I just right clicked, chose the menu "Encoding" and then a submenu appeared with a whole list of different languages (with Western European selected). So now I''m thinking that I have many different languages installed, and the correct language is selected at run time to show the appropriate web page?
Yes, I do realise that''s the way foward. I do intend to change my code to use numbers instead, and then I''m quite sure it will work as intended. I am still curious whether the letter system would work or not, and the knowledge I gain from the answer may be relevant and useful.
Yes, I know that a letter is really a number until you print it - but I''m not so sure that''s true in Visual Basic. Because, to convert between a letter and number or vice versa, you must use the Asc() and Chr() functions. I would imagine that these functions involve the character set and language installed on your system. Therefore the functions may act differently on different computers, giving me the wrong results.
Since we can all read the internet and HTML pages with our web browsers from anywhere in the world, and "hello world" does not change to "hello kitty", it leads me to think that it doesn''t matter which language the user has. But using Internet Explorer 6, I just right clicked, chose the menu "Encoding" and then a submenu appeared with a whole list of different languages (with Western European selected). So now I''m thinking that I have many different languages installed, and the correct language is selected at run time to show the appropriate web page?
July 07, 2002 08:29 PM
An ''a'' input as a single byte on one system will output an ''a'' on another system, provided it correctly supports ASCII. The ASCII character set is only 128 characters (0-127) and therfore should be correctly represented on any system, no matter wether it uses signed, or unsigned chars to represent the characters.
I would guess that the Asc() and Chr() functions in VB are just similar to casting to char or casting to int in C??
Anyway, your letters should come out right. If you want to think about other languages etc. a little more, you should check out "wide characters" and "locales". I''m not sure in what way VB supports/uses these, i''ve never used VB.
I would guess that the Asc() and Chr() functions in VB are just similar to casting to char or casting to int in C??
Anyway, your letters should come out right. If you want to think about other languages etc. a little more, you should check out "wide characters" and "locales". I''m not sure in what way VB supports/uses these, i''ve never used VB.
OK, thanks thats good news and makes things clearer for me
I'll put those keywords in a search engine or MSDN or something. I've used C++ a little and I can see that strings are handled differently.
I'll remember you guys when my game is a bestseller lol
[edited by - bazee on July 7, 2002 10:09:37 PM]
![](smile.gif)
I'll put those keywords in a search engine or MSDN or something. I've used C++ a little and I can see that strings are handled differently.
I'll remember you guys when my game is a bestseller lol
[edited by - bazee on July 7, 2002 10:09:37 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement