title: Dart socket doesn't send utf-8 chars below 31
body: <p>So, I and 2 friends are currently working on a project. One of them is programming a server, the other one a website, and me an app. At first, our programs should communicate with each other without encryption. This has also worked well. But now we wanted to encrypt the messages using AES 256 CBC. And that's when the problems started. At first, the encryption itself did not work properly, but now it works.</p>
  <p>However, when sending the encrypted message, some characters are not sent. Apparently, the characters below 32, i.e. all values that have only the value &quot;control&quot; according to the UTF8 table. However, I do not know how to work around the problem. we have also tested if it is not the server, but neither the website nor a quickly written Java program had this problem. Therefore we assume that the error is on my side.</p>
  <p>Here is the code I use to encrypt:</p>
  <pre><code>String encrypt(String  pKey, pIV, msg){
  
  
    final key = Key.fromUtf8(pKey);
    final iv = IV.fromUtf8(pIV);
  
    final encrypter = Encrypter(AES(key, mode: AESMode.cbc));
    final encrypted = encrypter.encrypt(msg, iv: iv);
    String utf8Msg = &quot;&quot;;
    for(int i = 0;i&lt;encrypted.bytes.length;i++ ){
      utf8Msg += String.fromCharCode(encrypted.bytes[i]);
    }
    print(&quot;###AES encrypted text: ${utf8Msg}&quot;) ;
    return utf8Msg;
  </code></pre>
  <p>And this is the code I use to send my Messages:</p>
  <pre><code>Future&lt;void&gt; run(String ip, int port, String request, key, iv) async {
    i = 0;
    String _request = request;
    Completer&lt;String&gt; _completer = new Completer&lt;String&gt;();
    print(&quot;Request: $_request&quot;);
    _errorData = &quot;Server_Error&quot;;
    if (_request != null) {
      print(&quot;Request has data&quot;);
      socket = await Socket.connect(ip, port);
      socket.encoding = utf8;
  
      socket.listen((data) {
        //code for the received messages
  
      },
      onError: ((error, StackTrace trace) {
        _secureResponse = _errorData;
        print(&quot;(2) $_secureResponse&quot;);
        _completer.completeError(_secureResponse);
      }),
      onDone: () {
        print(&quot;finish&quot;);
        _completer.complete(_secureResponse);
        socket.destroy();
      },
      cancelOnError: false);
      print(&quot;Socket sends data&quot;);
  
      socket.write(encrypt(key, iv, msg))
  
    } else {
      _secureResponse = _errorData;
      print(&quot;(4) $_secureResponse&quot;);
    }
  
    return _completer.future;
  }
  </code></pre>