diff options
author | 2016-06-15 08:52:26 -0400 | |
---|---|---|
committer | 2016-06-15 08:52:26 -0400 | |
commit | a09f1751c01d66a3b7519c72909746611d12a7f2 (patch) | |
tree | 0e1dc7d20b6f66100589e5e28f289dbeeed31d35 | |
parent | 16bf7c94537afe0883b1e80b2dbdbfaf7e6d391a (diff) |
Allow binary files to be encoded in something else.
UTF-16 files (and other encodings with null bytes) are initially recognized as
binary files (no encoding). Allow encodings to be set for such files after load.
-rw-r--r-- | core/file_io.lua | 10 | ||||
-rw-r--r-- | core/locale.conf | 1 | ||||
-rw-r--r-- | core/locales/locale.ar.conf | 1 | ||||
-rw-r--r-- | core/locales/locale.de.conf | 1 | ||||
-rw-r--r-- | core/locales/locale.es.conf | 1 | ||||
-rw-r--r-- | core/locales/locale.fr.conf | 1 | ||||
-rw-r--r-- | core/locales/locale.it.conf | 1 | ||||
-rw-r--r-- | core/locales/locale.pl.conf | 1 | ||||
-rw-r--r-- | core/locales/locale.ru.conf | 1 | ||||
-rw-r--r-- | core/locales/locale.sv.conf | 1 |
10 files changed, 6 insertions, 13 deletions
diff --git a/core/file_io.lua b/core/file_io.lua index bd018e5a..62966f3a 100644 --- a/core/file_io.lua +++ b/core/file_io.lua @@ -173,17 +173,19 @@ end -- LuaDoc is in core/.buffer.luadoc. local function set_encoding(buffer, encoding) - assert(buffer.encoding, _L['Cannot change binary file encoding']) local pos, first_visible_line = buffer.current_pos, buffer.first_visible_line local text = buffer:get_text() - text = text:iconv(buffer.encoding, 'UTF-8') - text = text:iconv(encoding, buffer.encoding) - text = text:iconv('UTF-8', encoding) + if buffer.encoding then + text = text:iconv(buffer.encoding, 'UTF-8') + if encoding then text = text:iconv(encoding, buffer.encoding) end + end + if encoding then text = text:iconv('UTF-8', encoding) end buffer:clear_all() buffer:add_text(text, #text) buffer:line_scroll(0, first_visible_line) buffer:goto_pos(pos) buffer.encoding = encoding + buffer.code_page = buffer.encoding and buffer.CP_UTF8 or 0 end -- Sets the default buffer encoding. events_connect(events.BUFFER_NEW, function() diff --git a/core/locale.conf b/core/locale.conf index 2faad95a..8f1d8cf2 100644 --- a/core/locale.conf +++ b/core/locale.conf @@ -20,7 +20,6 @@ Undefined event name = Undefined event name # core/file_io.lua Open = Open Encoding conversion failed. = Encoding conversion failed. -Cannot change binary file encoding = Cannot change binary file encoding Save = Save Untitled = Untitled Close without saving? = Close without saving? diff --git a/core/locales/locale.ar.conf b/core/locales/locale.ar.conf index 97ccb0f5..5d241fdd 100644 --- a/core/locales/locale.ar.conf +++ b/core/locales/locale.ar.conf @@ -21,7 +21,6 @@ Undefined event name = اسم حدث غير معرّف # core/file_io.lua Open = افتح Encoding conversion failed. = فشل تحويل الترميز. -Cannot change binary file encoding = لا يمكن تغيير ترميز الملف الثنائي Save = احفظ Untitled = بدون-عنوان Close without saving? = أَتُغلِق بدون حفظ؟ diff --git a/core/locales/locale.de.conf b/core/locales/locale.de.conf index cf8b6afe..ffdb8d1a 100644 --- a/core/locales/locale.de.conf +++ b/core/locales/locale.de.conf @@ -21,7 +21,6 @@ Undefined event name = Undefinierter Eventname # core/file_io.lua Open = Öffnen Encoding conversion failed. = Fehler bei der Umwandlung der Zeichenkodierung. -Cannot change binary file encoding = Binäres Dateiformat kann nicht geändert werden Save = Speichern Untitled = Unbenannt Close without saving? = Schließen ohne zu speichern? diff --git a/core/locales/locale.es.conf b/core/locales/locale.es.conf index 22b67098..db2a2d34 100644 --- a/core/locales/locale.es.conf +++ b/core/locales/locale.es.conf @@ -21,7 +21,6 @@ Undefined event name = Nombre de evento sin definir # core/file_io.lua Open = Abrir Encoding conversion failed. = Error al convertir codificación. -Cannot change binary file encoding = No se ha podido cambiar la codificación del fichero binario Save = Guardar Untitled = Sin Nombre Close without saving? = ¿Cerrar sin guardar? diff --git a/core/locales/locale.fr.conf b/core/locales/locale.fr.conf index d71559f1..e01eeb47 100644 --- a/core/locales/locale.fr.conf +++ b/core/locales/locale.fr.conf @@ -22,7 +22,6 @@ Undefined event name = Nom d’évènement inconnu # core/file_io.lua Open = Ouvrir Encoding conversion failed. = Échec de la conversion d’encodage -Cannot change binary file encoding = Impossible de modifier l’encodage d’un fichier binaire Save = Enregistrer Untitled = Sans titre Close without saving? = Fermer sans enregistrer? diff --git a/core/locales/locale.it.conf b/core/locales/locale.it.conf index 9a164a53..dd278e70 100644 --- a/core/locales/locale.it.conf +++ b/core/locales/locale.it.conf @@ -21,7 +21,6 @@ Undefined event name = Nome di evento indefinito # core/file_io.lua Open = Apri Encoding conversion failed. = Cambio di codifica non riuscito -Cannot change binary file encoding = Impossibile cambiare la codifica di un file binario Save = Salva Untitled = Senza titolo Close without saving? = Chiudere senza salvare? diff --git a/core/locales/locale.pl.conf b/core/locales/locale.pl.conf index 5c437087..6864a64e 100644 --- a/core/locales/locale.pl.conf +++ b/core/locales/locale.pl.conf @@ -21,7 +21,6 @@ Undefined event name = Brak nazwy zdarzenia # core/file_io.lua Open = Otwórz Encoding conversion failed. = Zmiana kodowania nie powiodła się. -Cannot change binary file encoding = Nie można zmienić kodowania pliku binarnego Save = Zapisz Untitled = Bez nazwy Close without saving? = Zamknąć bez zapisywania zmian? diff --git a/core/locales/locale.ru.conf b/core/locales/locale.ru.conf index 81792a32..55364fed 100644 --- a/core/locales/locale.ru.conf +++ b/core/locales/locale.ru.conf @@ -21,7 +21,6 @@ Undefined event name = Неизвестное название события # core/file_io.lua Open = Открыть Encoding conversion failed. = Ошибка при преобразовании кодировки. -Cannot change binary file encoding = Невозможно изменить кодировку двоичного файла Save = Сохранить Untitled = Безымянный Close without saving? = Закрыть без сохранения? diff --git a/core/locales/locale.sv.conf b/core/locales/locale.sv.conf index 2269f334..e405964d 100644 --- a/core/locales/locale.sv.conf +++ b/core/locales/locale.sv.conf @@ -21,7 +21,6 @@ Undefined event name = Odefinierat event-namn # core/file_io.lua Open = Öppna Encoding conversion failed. = Kunde inte konvertera teckenkodningen. -Cannot change binary file encoding = Kan inte ändra binär filkodning Save = Spara Untitled = Namnlös Close without saving? = Stäng utan att spara? |