try to get default charset from LANG if not in config
This commit is contained in:
parent
c9b9b14a78
commit
4a42edf4a1
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.22 2006-01-23 13:32:28 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.23 2006-03-20 09:51:45 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -136,6 +136,28 @@ bool RclConfig::getConfParam(const std::string &name, bool *bvp)
|
||||
return true;
|
||||
}
|
||||
|
||||
// If defcharset was set (from the config or a previous call), use it.
|
||||
// Else, try to guess it from LANG.
|
||||
// Use iso8859-1 as ultimate default
|
||||
// defcharset is reset on setKeyDir()
|
||||
const string& RclConfig::getDefCharset()
|
||||
{
|
||||
if (defcharset.empty()) {
|
||||
const char *cp;
|
||||
if ((cp = getenv("LANG"))) {
|
||||
cp = strrchr(cp, '.');
|
||||
if (cp) {
|
||||
cp++;
|
||||
if (*cp)
|
||||
defcharset = string(cp);
|
||||
}
|
||||
}
|
||||
if (defcharset.empty())
|
||||
defcharset = string("ISO8859-1");
|
||||
}
|
||||
return defcharset;
|
||||
}
|
||||
|
||||
// Get all known document mime values. We get them from the mimeconf
|
||||
// 'index' submap: values not in there (ie from mimemap or idfile) can't
|
||||
// possibly belong to documents in the database.
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
*/
|
||||
#ifndef _RCLCONFIG_H_INCLUDED_
|
||||
#define _RCLCONFIG_H_INCLUDED_
|
||||
/* @(#$Id: rclconfig.h,v 1.15 2006-01-30 11:15:27 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
/* @(#$Id: rclconfig.h,v 1.16 2006-03-20 09:51:45 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
|
||||
#include <list>
|
||||
|
||||
@ -54,7 +54,7 @@ class RclConfig {
|
||||
/** Variant with autoconversion to bool */
|
||||
bool getConfParam(const std::string &name, bool *value);
|
||||
/** Get default charset for current keydir (was set during setKeydir) */
|
||||
const string &getDefCharset() {return defcharset;}
|
||||
const string &getDefCharset();
|
||||
/** Get guessCharset for current keydir (was set during setKeydir) */
|
||||
bool getGuessCharset() {return guesscharset;}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user