moved printableUrl() to pathut
This commit is contained in:
parent
5c18957833
commit
a0805cf19a
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#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
|
#endif
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -111,18 +111,6 @@ bool startHelpBrowser(const string &iurl)
|
|||||||
return false;
|
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
|
// The global preferences structure
|
||||||
PrefsPack prefs;
|
PrefsPack prefs;
|
||||||
|
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
#ifndef _GUIUTILS_H_INCLUDED_
|
#ifndef _GUIUTILS_H_INCLUDED_
|
||||||
#define _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
|
* jean-francois.dockes@wanadoo.fr
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -55,8 +55,6 @@ bool getStemLangs(list<string>& langs);
|
|||||||
/** Start a browser on the help document */
|
/** Start a browser on the help document */
|
||||||
extern bool startHelpBrowser(const string& url = "");
|
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) */
|
/** Holder for preferences (gets saved to user Qt prefs) */
|
||||||
class PrefsPack {
|
class PrefsPack {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#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
|
#endif
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -38,6 +38,7 @@ using std::stack;
|
|||||||
|
|
||||||
#include "autoconfig.h"
|
#include "autoconfig.h"
|
||||||
#include "pathut.h"
|
#include "pathut.h"
|
||||||
|
#include "transcode.h"
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#ifndef STATFS_INCLUDE
|
#ifndef STATFS_INCLUDE
|
||||||
@ -382,6 +383,17 @@ std::string url_encode(const std::string url, string::size_type offs)
|
|||||||
return out;
|
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
|
#else // TEST_PATHUT
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
#ifndef _PATHUT_H_INCLUDED_
|
#ifndef _PATHUT_H_INCLUDED_
|
||||||
#define _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 <string>
|
#include <string>
|
||||||
#include <list>
|
#include <list>
|
||||||
@ -52,6 +52,9 @@ extern list<string> path_dirglob(const string &dir,
|
|||||||
/// Encode according to rfc 1738
|
/// Encode according to rfc 1738
|
||||||
extern string url_encode(const string url,
|
extern string url_encode(const string url,
|
||||||
string::size_type offs);
|
string::size_type offs);
|
||||||
|
extern bool printableUrl(const string &fcharset,
|
||||||
|
const string &in, string &out);
|
||||||
|
|
||||||
/// Stat parameter and check if it's a directory
|
/// Stat parameter and check if it's a directory
|
||||||
extern bool path_isdir(const string& path);
|
extern bool path_isdir(const string& path);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user