\r
function encodingCommand (ev) {\r
if (ev.params[0]) {\r
- _kiwi.gateway.setEncoding(null, ev.params[0], function (msg) {\r
- _kiwi.app.panels().active.addMsg('', msg);\r
+ _kiwi.gateway.setEncoding(null, ev.params[0], function (success) {\r
+ if (success) {\r
+ _kiwi.app.panels().active.addMsg('', "Encoding modified to "+ev.params[0]);\r
+ } else {\r
+ _kiwi.app.panels().active.addMsg('', ev.params[0]+' is not a valid encoding');\r
+ }\r
});\r
+ } else {\r
+ _kiwi.app.panels().active.addMsg('', 'Encoding not specified');\r
+ _kiwi.app.panels().active.addMsg('', 'Usage: /encoding [NEW-ENCODING]');\r
}\r
}\r
\r
conf.max_server_conns = 0;
/*
-* Available encodings supported by the server
+* Default encoding to be used by the server
* As specified and limited to iconv-lite library support.
-* All upper-case. Default is the first element on the list.
*/
-conf.available_encodings = ['UTF-8', 'WINDOWS-1252'];
+conf.default_encoding = 'UTF-8';
/*
* Client side plugins
\r
ENCODING: function (args, irc_connection, callback) {\r
if (args.encoding) {\r
- if (irc_connection.setEncoding(args.encoding)) {\r
- return callback('Encoding modified to '+args.encoding);\r
- } else {\r
- return callback(args.encoding+' is not a valid encoding');\r
- }\r
+ return callback(irc_connection.setEncoding(args.encoding));\r
}\r
}\r
};\r
this.setMaxListeners(0);
// Set the first configured encoding as the default encoding
- this.encoding = global.config.available_encodings[0];
+ this.encoding = global.config.default_encoding;
// Socket state
this.connected = false;
*/
IrcConnection.prototype.setEncoding = function (encoding) {
- if (global.config.available_encodings.indexOf(encoding.toUpperCase()) >= 0) {
- this.encoding = encoding.toUpperCase();
- return true;
+ try {
+ encoded_test = iconv.encode("TEST", encoding);
+ //This test is done to check if this encoding also supports
+ //the ASCII charset required by the IRC protocols
+ //(Avoid the use of base64 or incompatible encodings)
+ if (encoded_test == "TEST") {
+ this.encoding = encoding;
+ return true;
+ }
+ return false;
+ } catch (err) {
+ return false;
}
- return false;
};