Exemplo n.º 1
0
 // default implementation is empty
 /// <summary>
 /// Checks if the given argument is legal as this encoder's replacement byte
 /// array.
 /// </summary>
 /// <remarks>
 /// Checks if the given argument is legal as this encoder's replacement byte
 /// array.
 /// The given byte array is legal if and only if it can be decode into
 /// sixteen bits Unicode characters.
 /// This method can be overridden for performance improvement.
 /// </remarks>
 /// <param name="replacement">the given byte array to be checked.</param>
 /// <returns>
 /// true if the the given argument is legal as this encoder's
 /// replacement byte array.
 /// </returns>
 public virtual bool isLegalReplacement(byte[] replacement_1)
 {
     if (decoder == null)
     {
         decoder = cs.newDecoder();
         decoder.onMalformedInput(java.nio.charset.CodingErrorAction.REPORT);
         decoder.onUnmappableCharacter(java.nio.charset.CodingErrorAction.REPORT);
     }
     java.nio.ByteBuffer @in  = java.nio.ByteBuffer.wrap(replacement_1);
     java.nio.CharBuffer @out = java.nio.CharBuffer.allocate((int)(replacement_1.Length
                                                                   * decoder.maxCharsPerByte()));
     java.nio.charset.CoderResult result = decoder.decode(@in, @out, true);
     return(!result.isError());
 }