Best Way to Make Your Own Encoding

Martin recently asked what the best way to roll his own encoding in .Net 2.0, in particular can you override Encoding/Encoder/Decoder, or should he write his own StreamWriter.

#1 is, of course, to use Unicode :), but apparently Martin doesn't have that option.

The answer is that you can write your own Encoding derived from the Encoding class and use it as any of the built-in Encodings.  They'll be a little slower in some cases due to some shortcuts we take internally, but otherwise you should be able to use them everywhere you use a normal Encoding/Encoder/Decoder object. 

There's an example of using the fallbacks at, which isn't quite the same thing, but might help a little.

[updated 12 Oct 2006]
I've stuck an example of overriding encodings in this post: Example of overriding your own Encoding.

- Shawn