title: UTF-8 error in GtkTextView while decoding base64
body: <p>I have been trying to figure this out for a few days now. All I am trying to do is decode a base64 string and add it to a Gtk::TextView. Below is the code:</p>
  
  <pre><code>txtbuffer_ = Gtk::TextBuffer::create();
  txtview_.set_buffer(txtbuffer_);
  const Glib::ustring str = Glib::Base64::decode("YmJi3A==");
  txtbuffer_-&gt;set_text(str);
  </code></pre>
  
  <p>When I run the program I get the error:</p>
  
  <pre><code>Gtk-CRITICAL **: gtk_text_buffer_emit_insert: assertion 'g_utf8_validate (text, len, NULL)' failed
  </code></pre>
  
  <p>This error only occurs with Unicode characters. When the text is ASCII it all works fine.
  I have tried three different base64 decoders, I tried using std::string and Glib::ustring with all the different decoders. I also tried using the function <code>Glib::locale_to_utf8()</code>, but that gives me the error <code>terminate called after throwing an instance of 'Glib::ConvertError'</code>. And I tried using <code>Glib::convert</code> with the same error.</p>
  
  <p>I know that Gtk::TextView can display Unicode because if I set the text to a string with Unicode it will display the text.
  I read that Gtk::TextView displays text in UTF-8, so I think my problem is that the decoded string is not coded in UTF-8, but I am not sure. So my question is how can I get Gtk::TextView to display the decoded base64?</p>
  
  <p>Added note: I am using version 3.8 of Gtkmm</p>
  
  <p>Tested using version 3.12, same error message</p>
  
  <p>Minimal program:</p>
  
  <p>//test.h</p>
  
  <pre><code>#ifndef TEST_H_
  #define TEST_H_
  
  #include &lt;gtkmm.h&gt;
  
  class MainWindow : public Gtk::Window
  {
  public:
      MainWindow();
      virtual ~MainWindow();
  
  protected:
      Gtk::Box box_main;
      Gtk::TextView txtview_;
      Glib::RefPtr&lt;Gtk::TextBuffer&gt; txtbuffer_;
  };
  
  #endif /* TEST_H_ */
  </code></pre>
  
  <p>//test.cpp</p>
  
  <pre><code>#include "test.h"
  
  MainWindow::MainWindow()
  {   
      Gtk::Window::add(box_main);
  
      box_main.pack_start(txtview_);
  
      txtbuffer_ = Gtk::TextBuffer::create();
      txtview_.set_buffer(txtbuffer_);
      const Glib::ustring str = Glib::Base64::decode("YmJi3A==");
      txtbuffer_-&gt;set_text(str);
  
      Gtk::Window::show_all_children();
  }
  
  MainWindow::~MainWindow()
  {
  
  }
  </code></pre>
  
  <p>//main.cpp</p>
  
  <pre><code>#include "test.h"
  
  int main(int argc, char* argv[])
  {
      Glib::RefPtr&lt;Gtk::Application&gt; app = Gtk::Application::create(argc, argv, "test.program");
  
      MainWindow mw;
  
      return app-&gt;run(mw);
  }
  </code></pre>