Lecture overview -- Keyboard shortcut: 'u'  Previous page: Readers and Writers in C# -- Keyboard shortcut: 'p'  Next page: Sample use of class Encoding  -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home  Page 10 : 40
Object-oriented Programming in C#
Input and Output Classes
The class Encoding

An encoding is a mapping between characters/strings and byte arrays

An object of class System.Text.Encoding represents knowledge about a particular character encoding

 

  • byte[] GetBytes(string)       Instance method

  • byte[] GetBytes(char[])       Instance method

    • Encodes a string/char array to a byte array relative to the current encoding

  • char[] GetChars(byte[])       Instance method

    • Decodes a byte array to a char array relative to the current encoding

  • byte[] Convert(Encoding, Encoding, byte[])       Static method

    • Converts a byte array from one encoding (first parameter) to another encoding (second parameter)