User Tools

Site Tools


encodings
no way to compare when less than two revisions

Differences

This shows you the differences between two versions of the page.


encodings [2018/01/27 20:12] (current) – created wolfgangriedmann
Line 1: Line 1:
 +====== Encodings ======
 +
 +Since all strings in .NET are Unicode strings (see [[string_char_byte|String, Char and Byte]], you need to use the right encoding when reading and writing (disk, network, database).
 +
 +For the Encodings please see the classes that inherit from the [[https://docs.microsoft.com/en-us/dotnet/api/system.text.encoding|System.Text.Encoding]] class:
 +
 +  * System.Text.ASCIIEncoding: 7 bit ASCII 
 +  * System.Text.UnicodeEncoding: UTF-16 Unicode
 +  * System.Text.UTF32Encoding: UTF-32 Unicode
 +  * System.Text.UTF7Encoding: UTF-7 Unicode
 +  * System.Text.UTF8Encoding: UTF-8 Unicode
 +
 +The Encoding class has a few very interesting static methods (please see MSDN for further details):
 +
 +  * Convert converts a byte array from one encoding to another
 +  * GetBytes converts a character array or a string to a byte array
 +  * GetChars converts a byte array to a char array
 +  * GetString converts a byte array to a string
 +
 +It may sound difficult, but it is neccessary to understand the encodings when you deal with different systems (disk, database, network). Otherwise you will corrupt your data.
  
encodings.txt · Last modified: 2018/01/27 20:12 by wolfgangriedmann