From f3bbcd9476beec7c43d2adb3bc0129ff8041d7ad Mon Sep 17 00:00:00 2001 From: svntobi Date: Sat, 25 Aug 2007 19:46:15 +0000 Subject: Fixed charset conversion for menu titles. They will now explicitly be converted to VDR's locale charset falling back to ISO8859-2 on conversion errors. git-svn-id: file:///home/tobias/sandbox/vdr/--/vdr-pkg/vdr-pkg/menuorg/trunk@5986 cd0d6b48-d4f9-0310-940f-ab8c4eb44d3f --- src/menuconfiguration.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/menuconfiguration.cpp') diff --git a/src/menuconfiguration.cpp b/src/menuconfiguration.cpp index f096ba2..b9c01b4 100644 --- a/src/menuconfiguration.cpp +++ b/src/menuconfiguration.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include "systemmenunode.h" #include "submenunode.h" #include "pluginmenunode.h" @@ -94,7 +95,7 @@ void MenuConfiguration::ParseElement(const Element* element, MenuNode* menuNode) const xmlpp::Attribute* nameAttribute = childElement->get_attribute("name"); string type = childElement->get_name(); - string name = nameAttribute->get_value(); + string name = UnicodeToLocaleOrIso8859(nameAttribute->get_value()); if ( type == "menu") { @@ -208,3 +209,15 @@ void MenuConfiguration::AddCommandMenuNode(string name, string command, bool con { menu->AddChild(new CommandMenuNode(name, command, confirm)); } + +string MenuConfiguration::UnicodeToLocaleOrIso8859(Glib::ustring unicodeString) +{ + try + { + return Glib::locale_from_utf8(unicodeString); + } + catch (Glib::ConvertError) + { + return Glib::convert_with_fallback(unicodeString, "ISO8859-2", "UTF-8"); + } +} -- cgit v1.2.3