for (int i = 0; i < length; i++) {
      char c = target.charAt(i);
      if (c == 0x0D) {
        writer.write(XD);
      } else {