6
internal class CharsetDecoder
11
public CharsetDecoder (Encoding enc)
14
this.decoder = enc.GetDecoder ();
17
public string Decode (ByteBuffer b)
19
string res = enc.Decode (b);
20
if (res.IndexOf ('\uFFFD') != -1 && decoder.Fallback == DecoderFallback.ExceptionFallback)
21
throw new CharacterCodingException ();
25
public void OnMalformedInput (CodingErrorAction action)
27
if (action == CodingErrorAction.REPORT)
28
decoder.Fallback = DecoderFallback.ExceptionFallback;
30
decoder.Fallback = DecoderFallback.ReplacementFallback;
33
public void OnUnmappableCharacter (CodingErrorAction action)
35
if (action == CodingErrorAction.REPORT)
36
decoder.Fallback = DecoderFallback.ExceptionFallback;
38
decoder.Fallback = DecoderFallback.ReplacementFallback;