moved printableUrl() to pathut

This commit is contained in:
dockes
2008-07-01 08:26:08 +00:00
parent 5c18957833
commit a0805cf19a
4 changed files with 19 additions and 18 deletions
+13 -1
View File
@@ -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 <sys/types.h>
#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 <iostream>
+4 -1
View File
@@ -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 <string>
#include <list>
@@ -52,6 +52,9 @@ extern list<string> 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);