diff --git a/src/common/rclconfig.cpp b/src/common/rclconfig.cpp index 02d70d1c..13d56926 100644 --- a/src/common/rclconfig.cpp +++ b/src/common/rclconfig.cpp @@ -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. diff --git a/src/common/rclconfig.h b/src/common/rclconfig.h index 1992bd71..f1bfe460 100644 --- a/src/common/rclconfig.h +++ b/src/common/rclconfig.h @@ -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 @@ -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;}