anchor.diff:  	    io_reply(From, ReplyAs, Reply),
   	    Q1;
   	{exit,What} ->
  -	    send_port(Port, close),
  +	    ok = send_port(Port, close),
   	    exit(What)
       end.
   
   %% New in R13B
   %% Encoding option (unicode/latin1)
   io_request({put_chars,unicode,Chars}, Port, Q) -> % Binary new in R9C
  -    put_chars(wrap_characters_to_binary(Chars,unicode, get(encoding)), Port, Q);
  +    case wrap_characters_to_binary(Chars, unicode, get(encoding)) of
  +        error ->
  +            {error,{error,put_chars},Q};
  +        Bin ->
  +           put_chars(Bin, Port, Q)
  +    end;
   io_request({put_chars,unicode,Mod,Func,Args}, Port, Q) ->
  -    Result = case catch apply(Mod,Func,Args) of
  -		 Data when is_list(Data); is_binary(Data) ->
  -		     wrap_characters_to_binary(Data,unicode,get(encoding));
  -		 Undef ->
  -		     Undef
  -	     end,
  -    put_chars(Result, Port, Q);
  +    case catch apply(Mod,Func,Args) of
  +        Data when is_list(Data); is_binary(Data) ->
  +            case wrap_characters_to_binary(Data, unicode, get(encoding)) of
  +                Bin when is_binary(Bin) ->
  +                    put_chars(Bin, Port, Q);
  +                error ->
  +                    {error,{error,put_chars},Q}
  +            end;
  +        Undef ->
  +            put_chars(Undef, Port, Q)
  +    end;
   io_request({put_chars,latin1,Chars}, Port, Q) -> % Binary new in R9C
  -    Data = case get(encoding) of
  -	       unicode ->
  -		   unicode:characters_to_binary(Chars,latin1,unicode);
  -	       latin1 ->
  -		   erlang:iolist_to_binary(Chars)
  -	   end,
  -    put_chars(Data, Port, Q);
  +    case catch unicode:characters_to_binary(Chars, latin1, get(encoding)) of
  +        Data when is_binary(Data) ->
  +            put_chars(Data, Port, Q);
  +        _ ->
  +            {error,{error,put_chars},Q}
  +    end;
   io_request({put_chars,latin1,Mod,Func,Args}, Port, Q) ->
  -    Result = case catch apply(Mod,Func,Args) of
  -		 Data when is_list(Data); is_binary(Data) ->
  -		     unicode:characters_to_binary(Data,latin1,get(encoding));
  -		 Undef ->
  -		     Undef
  -	     end,
  -    put_chars(Result, Port, Q);
  +    case catch apply(Mod,Func,Args) of
  +        Data when is_list(Data); is_binary(Data) ->
  +            case
  +                catch unicode:characters_to_binary(Data,latin1,get(encoding))
  +            of
  +                Bin when is_binary(Bin) ->
  +                    put_chars(Bin, Port, Q);
  +                _ ->
  +                    {error,{error,put_chars},Q}
  +            end;
  +        Undef ->
  +            put_chars(Undef, Port, Q)
  +    end;
   io_request({get_chars,Enc,Prompt,N}, Port, Q) -> % New in R9C
       get_chars(Prompt, io_lib, collect_chars, N, Port, Q, Enc);
   io_request({get_line,Enc,Prompt}, Port, Q) ->
  
positive.code:     
  %% Entry function.
  get_chars(Prompt, M, F, Xa, Port, Q, Enc) ->
      prompt(Port, Prompt),
      case {get(eof),queue:is_empty(Q)} of
  	{true,true} ->
  	    {ok,eof,Q};
  	_ ->
  	    get_chars(Prompt, M, F, Xa, Port, Q, start, Enc)
      end.
  
  %% First loop. Wait for port data. Respond to output requests.
  
negative.code: get_chars_req(Prompt, M, F, XtraArg, Port, Q, State,
  	      Req, From, ReplyAs, Enc) ->
      do_io_request(Req, From, ReplyAs, Port, queue:new()), %Keep Q over this call
      case prompt(Port, Prompt) of
          error ->
              {error,{error,get_chars},Q};
          ok ->
              get_chars(Prompt, M, F, XtraArg, Port, Q, State, Enc)
      end.
  
  %% Second loop. Pass data to client as long as it wants more.
  %% A ^G in data interrupts loop if 'noshell' is not undefined.
  