From a0805cf19a2b57cb96e8fc65ee904235378ce793 Mon Sep 17 00:00:00 2001 From: dockes Date: Tue, 1 Jul 2008 08:26:08 +0000 Subject: [PATCH] moved printableUrl() to pathut --- src/qtgui/guiutils.cpp | 14 +------------- src/qtgui/guiutils.h | 4 +--- src/utils/pathut.cpp | 14 +++++++++++++- src/utils/pathut.h | 5 ++++- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/qtgui/guiutils.cpp b/src/qtgui/guiutils.cpp index cf5a7e48..9856a0a6 100644 --- a/src/qtgui/guiutils.cpp +++ b/src/qtgui/guiutils.cpp @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "@(#$Id: guiutils.cpp,v 1.36 2008-05-05 20:24:55 dockes Exp $ (C) 2005 Jean-Francois Dockes"; +static char rcsid[] = "@(#$Id: guiutils.cpp,v 1.37 2008-07-01 08:26:08 dockes Exp $ (C) 2005 Jean-Francois Dockes"; #endif /* * This program is free software; you can redistribute it and/or modify @@ -111,18 +111,6 @@ bool startHelpBrowser(const string &iurl) return false; } -// Printable url: either utf-8 if transcoding succeeds, or url-encoded -bool printableUrl(const string &in, string &out) -{ - string fcharset = rclconfig->getDefCharset(true); - int ecnt = 0; - if (!transcode(in, out, fcharset, "UTF-8", &ecnt) || ecnt) { - out = url_encode(in, 7); - } - return true; -} - - // The global preferences structure PrefsPack prefs; diff --git a/src/qtgui/guiutils.h b/src/qtgui/guiutils.h index ed60c29e..908962cf 100644 --- a/src/qtgui/guiutils.h +++ b/src/qtgui/guiutils.h @@ -17,7 +17,7 @@ #ifndef _GUIUTILS_H_INCLUDED_ #define _GUIUTILS_H_INCLUDED_ /* - * @(#$Id: guiutils.h,v 1.26 2008-05-05 20:24:55 dockes Exp $ (C) 2005 Jean-Francois Dockes + * @(#$Id: guiutils.h,v 1.27 2008-07-01 08:26:08 dockes Exp $ (C) 2005 Jean-Francois Dockes * jean-francois.dockes@wanadoo.fr * * This program is free software; you can redistribute it and/or modify @@ -55,8 +55,6 @@ bool getStemLangs(list& langs); /** Start a browser on the help document */ extern bool startHelpBrowser(const string& url = ""); -/** Try to make an utf8 printable url */ -extern bool printableUrl(const string &in, string &out); /** Holder for preferences (gets saved to user Qt prefs) */ class PrefsPack { diff --git a/src/utils/pathut.cpp b/src/utils/pathut.cpp index 63cf0e0c..00b86c49 100644 --- a/src/utils/pathut.cpp +++ b/src/utils/pathut.cpp @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "@(#$Id: pathut.cpp,v 1.20 2008-06-13 18:22:47 dockes Exp $ (C) 2004 J.F.Dockes"; +static char rcsid[] = "@(#$Id: pathut.cpp,v 1.21 2008-07-01 08:26:08 dockes Exp $ (C) 2004 J.F.Dockes"; #endif /* * This program is free software; you can redistribute it and/or modify @@ -38,6 +38,7 @@ using std::stack; #include "autoconfig.h" #include "pathut.h" +#include "transcode.h" #include #ifndef STATFS_INCLUDE @@ -382,6 +383,17 @@ std::string url_encode(const std::string url, string::size_type offs) return out; } +// Printable url: this is used to transcode from the system charset +// into either utf-8 if transcoding succeeds, or url-encoded +bool printableUrl(const string &fcharset, const string &in, string &out) +{ + int ecnt = 0; + if (!transcode(in, out, fcharset, "UTF-8", &ecnt) || ecnt) { + out = url_encode(in, 7); + } + return true; +} + #else // TEST_PATHUT #include diff --git a/src/utils/pathut.h b/src/utils/pathut.h index 7c45ac79..cc2f3cfd 100644 --- a/src/utils/pathut.h +++ b/src/utils/pathut.h @@ -16,7 +16,7 @@ */ #ifndef _PATHUT_H_INCLUDED_ #define _PATHUT_H_INCLUDED_ -/* @(#$Id: pathut.h,v 1.13 2007-06-08 15:30:01 dockes Exp $ (C) 2004 J.F.Dockes */ +/* @(#$Id: pathut.h,v 1.14 2008-07-01 08:26:08 dockes Exp $ (C) 2004 J.F.Dockes */ #include #include @@ -52,6 +52,9 @@ extern list path_dirglob(const string &dir, /// Encode according to rfc 1738 extern string url_encode(const string url, string::size_type offs); +extern bool printableUrl(const string &fcharset, + const string &in, string &out); + /// Stat parameter and check if it's a directory extern bool path_isdir(const string& path);