Beispiel #1
0
 /// <summary>
 /// Encode the given source using the character set.
 /// </summary>
 protected override ByteBuffer Encode(CharBuffer source)
 {
     if (throwOnInvalidBytes)
         return charSet.NewEncoder().OnMalformedInput(CodingErrorAction.REPORT).OnUnmappableCharacter(CodingErrorAction.REPORT)
                    .Encode(source);
     return base.Encode(source);
 }
Beispiel #2
0
 /// <summary>
 /// Encode the given source using the character set.
 /// </summary>
 protected virtual ByteBuffer Encode(CharBuffer source)
 {
     var replaceWith = new[] {(byte)'?'};
     var encoder =
         charSet.NewEncoder()
                .OnMalformedInput(CodingErrorAction.REPLACE)
                .OnUnmappableCharacter(CodingErrorAction.REPLACE)
                .ReplaceWith(replaceWith);
     return encoder.Encode(source);
 }