Game Development Reference
In-Depth Information
11.6.1.1 History of char
The number of different symbols that can be stored in a char variables has become
bigger throughout the years in different programming languages:
In the 1970s, programmers thought that 2 6
64 symbols would be enough:
26 letters, 10 numbers, and 28 punctuation marks (comma, semicolon, and so
on). Although this meant that there was no distinction between normal and capi-
tal letters, it was not a problem at the time.
=
In the 1980s, people used 2 7
128 different symbols: 26 capital letters, 26 nor-
mal letters, 10 numbers, 33 punctuation marks, and 33 special character (end-
of-line, tabulation, beep, and so on). The order of these symbols was known as
ASCII: the American Standard Code for Information Interchange. This was nice
for the English language, but it was not sufficient for other languages such as
French, German, Dutch, Spanish and more.
=
As a result, in the 1990s new code tables were constructed with 2 8
256 sym-
bols, where the most common letters for a country were represented as well.
The symbols from 0-127 were the same as in ASCII, but the symbols 128-255
were used for special characters belonging to a given language. Depending on
the language (English, Russian, Indian), a different code table was used. The
West-European code table was 'Latin1' for example. For Eastern-Europe, another
code table was used (Polish and Czech have many special accents for which there
was no more place in the Latin1 table). Greek, Russian, Hebrew, and the Indian
Devangari-alphabet all had their own code table. This was a reasonable way of
dealing with the different languages, but things became complicated once you
wanted to store a text in different languages at the same time. Also, languages
containing more than 128 symbols (such as Chinese) were impossible to repre-
sent using this format.
=
In the beginning of the 21st century, the coding standard was extended again to
a table containing 2 16
=
65 , 536 different symbols. This table could easily con-
tain all the alphabets in the world, including many different punctuation marks
and other symbols. This code table is called Unicode . The first 256 symbols of
Unicode are the same symbols as the Latin1 code table.
In C#, char values are stored using the Unicode standard. Not all computers or all
fonts can actually display all these symbols, but at least we will not have to change
our programs when they can.
11.6.1.2 Using Single and Double Quotes
When using string and char values, you have to be careful which type of quotes you
use (if any). If you forget the quotes, you are not writing text or characters anymore,
but a piece of a C# program! There is a big difference between:
the string "hello" and the variable name hello
the string "bool" and the type name bool
Search WWH ::




Custom Search