From a50e83ea38dc3701619829c2d39fe46a29312938 Mon Sep 17 00:00:00 2001 From: John Spray Date: Tue, 14 Feb 2006 14:49:41 +0000 Subject: [PATCH] Fix copy and paste text encoding in GTK frontend git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13238 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/gtk/ChangeLog | 2 ++ src/frontends/gtk/GWorkArea.C | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/frontends/gtk/ChangeLog b/src/frontends/gtk/ChangeLog index 3e2352c8b6..1ef24a63d6 100644 --- a/src/frontends/gtk/ChangeLog +++ b/src/frontends/gtk/ChangeLog @@ -4,6 +4,8 @@ Now I can type Schrödinger. * codeConvert.h, Makefile.am: Remove codeConvert.h, it's no longer used. + * GWorkArea.C: fix copy and paste text encoding. Now + I can copy and paste Schrödinger. 2006-02-13 John Spray * ghelpers.C: implement Gtk::IconTheme stuff for getting diff --git a/src/frontends/gtk/GWorkArea.C b/src/frontends/gtk/GWorkArea.C index 9cb8a48231..bc2f7d290b 100644 --- a/src/frontends/gtk/GWorkArea.C +++ b/src/frontends/gtk/GWorkArea.C @@ -519,20 +519,26 @@ void GWorkArea::haveSelection(bool toHave) const } +// ENCODING: Gtk::Clipboard returns UTF-8, we assume that the backend +// wants ISO-8859-1 and convert it to that. string const GWorkArea::getClipboard() const { Glib::RefPtr clipboard = Gtk::Clipboard::get(GDK_SELECTION_PRIMARY); - return Glib::locale_from_utf8(clipboard->wait_for_text()); + return Glib::convert_with_fallback( + clipboard->wait_for_text(), "ISO-8859-1", "UTF-8"); } +// ENCODING: we assume that the backend passes us ISO-8859-1 and +// convert from that to UTF-8 before passing to GTK void GWorkArea::putClipboard(string const & str) const { Glib::RefPtr clipboard = Gtk::Clipboard::get(GDK_SELECTION_PRIMARY); - clipboard->set_text(Glib::locale_to_utf8(str)); + clipboard->set_text(Glib::convert(str, "UTF-8", "ISO-8859-1")); } + } // namespace frontend } // namespace lyx