diff --git a/index.html b/index.html
index 1430524..6b19974 100644
--- a/index.html
+++ b/index.html
@@ -80,6 +80,38 @@
+
+
diff --git a/js/client.js b/js/client.js
index 3354fa4..da93ebd 100644
--- a/js/client.js
+++ b/js/client.js
@@ -197,8 +197,7 @@ class PalaceProtocol {
connect(ip,port) {
- this.textDecoder = new TextDecoder('windows-1252'); // default server encoding
- this.textEncoder = new TextEncoder('windows-1252', { NONSTANDARD_allowLegacyEncoding: true }); // palace default! :\
+ this.setEncoder(prefs.general.encoding);
if (!port) port = '9998';
this.ip = ip.trim();
@@ -1160,6 +1159,10 @@ class PalaceProtocol {
this.send(packet);
}
+ setEncoder(encoding) {
+ this.textDecoder = new TextDecoder(encoding);
+ this.textEncoder = new TextEncoder(encoding, { NONSTANDARD_allowLegacyEncoding: true }); // palace default! :\
+ }
}
diff --git a/js/interface.js b/js/interface.js
index 64738ed..8c4088c 100644
--- a/js/interface.js
+++ b/js/interface.js
@@ -385,6 +385,15 @@ if (window.require) {
document.getElementById('prefhomepalace').onchange = function() {
setGeneralPref('home',this.value);
};
+ document.getElementById('prefencoding').onchange = function() {
+ try {
+ palace.setEncoder(this.value);
+ setGeneralPref('encoding',this.value);
+ } catch (error) {
+ logerror(error);
+ this.value = getGeneralPref('encoding');
+ }
+ };
document.getElementById('prefpropbagsize').oninput = function() { // change prop bag tile size :D
setGeneralPref('propBagTileSize',this.value);
refreshPropBagView(true);
diff --git a/js/preferences.js b/js/preferences.js
index 4517e37..b060249 100644
--- a/js/preferences.js
+++ b/js/preferences.js
@@ -20,8 +20,8 @@ function setGeneralPref(id,value) {
prefs.general[id] = value;
}
-function getGeneralPref(id) {
- return prefs.general[id];
+function getGeneralPref(id,def) {
+ return prefs.general.hasOwnProperty(id) ? prefs.general[id] : def;
}
window.onunload = function(e) {
@@ -66,4 +66,5 @@ window.onunload = function(e) {
}
document.getElementById('prefusername').value = getGeneralPref('userName');
document.getElementById('prefhomepalace').value = getGeneralPref('home');
+ document.getElementById('prefencoding').value = getGeneralPref('encoding','windows-1252');
})();