public ForwardingEncoder (Encoding enc) { var fallback = enc.EncoderFallback; if (fallback != null) Fallback = fallback; encoding = enc; }
// Convert between two encodings. public static byte[] Convert (Encoding srcEncoding, Encoding dstEncoding, byte[] bytes) { if (srcEncoding == null) throw new ArgumentNullException ("srcEncoding"); if (dstEncoding == null) throw new ArgumentNullException ("dstEncoding"); if (bytes == null) throw new ArgumentNullException ("bytes"); return dstEncoding.GetBytes (srcEncoding.GetChars (bytes, 0, bytes.Length)); }
public static byte[] Convert (Encoding srcEncoding, Encoding dstEncoding, byte[] bytes, int index, int count) { if (srcEncoding == null) throw new ArgumentNullException ("srcEncoding"); if (dstEncoding == null) throw new ArgumentNullException ("dstEncoding"); if (bytes == null) throw new ArgumentNullException ("bytes"); if (index < 0 || index > bytes.Length) throw new ArgumentOutOfRangeException ("index"); if (count < 0 || (bytes.Length - index) < count) throw new ArgumentOutOfRangeException ("count"); return dstEncoding.GetBytes (srcEncoding.GetChars (bytes, index, count)); }