patch 7.4.1288
Problem:    ch_sendexpr() does not use JS encoding.
Solution:   Use the encoding that fits the channel mode.  Refuse using
            ch_sendexpr() on a raw channel.
diff --git a/src/channel.c b/src/channel.c
index 8e36808..fef6de5 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -1514,4 +1514,17 @@
     }
     return abort;
 }
+
+/*
+ * Return the mode of channel "idx".
+ * If "idx" is invalid returns MODE_JSON.
+ */
+    ch_mode_T
+channel_get_mode(int idx)
+{
+    if (idx < 0 || idx >= channel_count)
+	return MODE_JSON;
+    return channels[idx].ch_mode;
+}
+
 #endif /* FEAT_CHANNEL */