| ||||||||||||||||||||||||||||
Encoding Base TypesGetting Started ASP.NET Base Types Characters are abstract entities that can be represented using many different character schemes or code pages. For example, Unicode UTF-16 encoding represents characters as sequences of 16-bit integers, while Unicode UTF-8 represents the same characters as sequences of 8-bit bytes. The common language runtime uses Unicode UTF-16 ( Unicode Transformation Format, 16-bit encoding form ) to represent characters. Applications that target the common language runtime use encoding to map character representations from the native character scheme to other schemes. Applications use decoding to map characters from non-native schemes to the native scheme. The following table lists the most commonly used classes in the System.Text namespace to encode and decode characters.
The following code example converts a Unicode string into an array of bytes using the ASCIIEncoding.GetBytes method. Each byte in the array represents the ASCII value for the letter in that position of the string.
which displays the following on the page. The byte 65 is the ASCII value for the A character; the byte 66 is the ASCII value for the B character, and so on. 65, 66, 67, 68, 69, 70, ... ... 86, 87, 88, 89, 90 The following code example converts the preceding array of bytes into an array of characters using the ASCIIEncoding class. The GetChars method is used to decode the array of bytes.
which displays the characters ABCDEFGHIJKLMNOPQRSTUVWXYZ on the page. See Also |
| |||||||||||||||||||||||||||
Check out related books at Amazon
© 2000-2008 Rey Nuñez All rights reserved.
If you have any question, comment or suggestion
about this site, please send us a note
You can help support aspxtreme