# HG changeset patch # User Markus Mützel # Date 1657809767 -7200 # Thu Jul 14 16:42:47 2022 +0200 # Node ID 6be1c264669c03b7a58000e327fda790f3a53ef9 # Parent f125ddb4605550e2d3881d4b211ecc4110d7502e WIP: file editor with dir_encoding diff -r f125ddb46055 -r 6be1c264669c libgui/src/m-editor/file-editor-tab.cc --- a/libgui/src/m-editor/file-editor-tab.cc Wed Jul 13 13:20:48 2022 +0200 +++ b/libgui/src/m-editor/file-editor-tab.cc Thu Jul 14 16:42:47 2022 +0200 @@ -84,6 +84,7 @@ #include "bp-table.h" #include "builtin-defun-decls.h" +#include "input.h" #include "interpreter-private.h" #include "interpreter.h" #include "load-path.h" @@ -1812,14 +1813,22 @@ text_data.chop (1); } + // get encoding for folders in load paths + // use default encoding for folders that are not in load path + std::string fdir = file_info.dir ().path ().toUtf8 ().toStdString (); + input_system& input_sys = __get_input_system__ (); + std::string encoding_str + = input_sys.dir_encoding (input_sys.load_path_dir (fdir)); + m_encoding = QString::fromStdString (encoding_str); + // decode QTextCodec::ConverterState st; - QTextCodec *codec = QTextCodec::codecForName (m_encoding.toLatin1 ()); + QTextCodec *codec = QTextCodec::codecForName (m_encoding.toUtf8 ()); if (codec == nullptr) codec = QTextCodec::codecForLocale (); - const QString text = codec->toUnicode(text_data.constData(), - text_data.size(), &st); + const QString text = codec->toUnicode(text_data.constData (), + text_data.size (), &st); // Decoding with invalid characters? if (st.invalidChars > 0) diff -r f125ddb46055 -r 6be1c264669c libinterp/corefcn/input.cc --- a/libinterp/corefcn/input.cc Wed Jul 13 13:20:48 2022 +0200 +++ b/libinterp/corefcn/input.cc Thu Jul 14 16:42:47 2022 +0200 @@ -536,7 +536,7 @@ } // Get part of the directory that would be added to the load path - static std::string load_path_dir (const std::string& dir) + std::string input_system::load_path_dir (const std::string& dir) { std::string lp_dir = dir; diff -r f125ddb46055 -r 6be1c264669c libinterp/corefcn/input.h --- a/libinterp/corefcn/input.h Wed Jul 13 13:20:48 2022 +0200 +++ b/libinterp/corefcn/input.h Thu Jul 14 16:42:47 2022 +0200 @@ -56,7 +56,7 @@ class interpreter; - class input_system + class OCTINTERP_API input_system { public: @@ -149,6 +149,8 @@ void set_dir_encoding (const std::string& dir, std::string& enc); + std::string load_path_dir (const std::string& dir); + octave_value auto_repeat_debug_command (const octave_value_list& args, int nargout);