From 13cc4db1c37f5161c8fc3bc8d74947c76b018648 Mon Sep 17 00:00:00 2001 From: Thomas Jarosch Date: Thu, 30 Mar 2006 09:05:13 +0000 Subject: [PATCH] ui, arniesetup, libi2ncommon: (tomj) po file is now in utf8 format. make use of new utf8 functions --- src/stringfunc.cpp | 41 ++++++++--------------------------------- src/stringfunc.hxx | 4 +--- 2 files changed, 9 insertions(+), 36 deletions(-) diff --git a/src/stringfunc.cpp b/src/stringfunc.cpp index 2cf0ddc..f7280f2 100644 --- a/src/stringfunc.cpp +++ b/src/stringfunc.cpp @@ -79,17 +79,17 @@ std::string utf8_to_iso(const std::string& utf8string) return result; } -std::string utf7imap_to_iso(const std::string& utf7imapstring) +std::string utf7imap_to_utf8(const std::string& utf7imapstring) { string result; - iconv_t utf7imap2iso = iconv_open ("ISO-8859-1","UTF-7-IMAP"); + iconv_t utf7imap2utf8 = iconv_open ("UTF-8","UTF-7-IMAP"); - if (utf7imap2iso == (iconv_t)-1) - throw runtime_error("iconv can't convert from UTF-7-IMAP to ISO-8859-1"); + if (utf7imap2utf8 == (iconv_t)-1) + throw runtime_error("iconv can't convert from UTF-7-IMAP to UTF-8"); size_t in_size=utf7imapstring.size(); - size_t out_size=in_size; + size_t out_size=in_size*4; char *buf = (char *)malloc(out_size+1); if (buf == NULL) @@ -97,39 +97,14 @@ std::string utf7imap_to_iso(const std::string& utf7imapstring) const char *in = utf7imapstring.c_str(); char *out = buf; - iconv (utf7imap2iso, &in, &in_size, &out, &out_size); + iconv (utf7imap2utf8, &in, &in_size, &out, &out_size); - buf[utf7imapstring.size()-out_size]=0; + buf[utf7imapstring.size()*4-out_size]=0; result=buf; free(buf); - iconv_close (utf7imap2iso); - - return result; -} - -// DEPRECATED, WILL BE REMOVED TOMORROW! -std::string iso_to_html(const std::string& isostring, bool showerr_bug) -{ - string result = isostring; - - // TODO: This needs to be removed soon by a proper - // HTML quoted chars engine. Then we can also remove ü from i18n files. - if (!showerr_bug) { - replace_all (result, "&", "&"); - replace_all (result, "\"", """); - replace_all (result, "<", "<"); - replace_all (result, ">", ">"); - } - - replace_all (result, utf8_to_iso("ä"), "ä"); - replace_all (result, utf8_to_iso("ö"), "ö"); - replace_all (result, utf8_to_iso("ü"), "ü"); - replace_all (result, utf8_to_iso("Ä"), "Ä"); - replace_all (result, utf8_to_iso("Ö"), "Ö"); - replace_all (result, utf8_to_iso("Ü"), "Ü"); - replace_all (result, utf8_to_iso("ß"), "ß"); + iconv_close (utf7imap2utf8); return result; } diff --git a/src/stringfunc.hxx b/src/stringfunc.hxx index 0fda2d1..d33b679 100644 --- a/src/stringfunc.hxx +++ b/src/stringfunc.hxx @@ -22,9 +22,7 @@ bool replace_all(std::string &base, const std::string &ist, const std::string &s std::string iso_to_utf8(const std::string& isostring); std::string utf8_to_iso(const std::string& utf8string); -std::string utf7imap_to_iso(const std::string &utf7imapstring); - -std::string iso_to_html(const std::string& isostring, bool showerr_bug); // DEPRECATED! +std::string utf7imap_to_utf8(const std::string &utf7imapstring); std::string strip_html_tags(const std::string &input); std::string smart_html_entities(const std::string &input); -- 1.7.1