"Fossies" - the Fresh Open Source Software Archive

Member "recoll-1.26.3/common/utf8fn.cpp" (4 Sep 2019, 1015 Bytes) of package /linux/privat/recoll-1.26.3.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "utf8fn.cpp" see the Fossies "Dox" file reference documentation.

    1 #include "utf8fn.h"
    2 #include "rclconfig.h"
    3 #include "transcode.h"
    4 #include "log.h"
    5 
    6 using namespace std;
    7 
    8 string compute_utf8fn(const RclConfig *config, const string& ifn, bool simple)
    9 {
   10     string lfn(simple ? path_getsimple(ifn) : ifn);
   11 #ifdef _WIN32
   12     // On windows file names are read as UTF16 wchar_t and converted to UTF-8
   13     // while scanning directories
   14     return lfn;
   15 #else
   16     string charset = config->getDefCharset(true);
   17     string utf8fn; 
   18     int ercnt;
   19     if (!transcode(lfn, utf8fn, charset, "UTF-8", &ercnt)) {
   20     LOGERR("compute_utf8fn: fn transcode failure from ["  << charset <<
   21                "] to UTF-8 for: [" << lfn << "]\n");
   22     } else if (ercnt) {
   23     LOGDEB("compute_utf8fn: "  << ercnt << " transcode errors from [" <<
   24                charset << "] to UTF-8 for: ["  << lfn << "]\n");
   25     }
   26     LOGDEB1("compute_utf8fn: transcoded from ["  << lfn << "] to ["  <<
   27             utf8fn << "] ("  << charset << "->"  << "UTF-8)\n");
   28     return utf8fn;
   29 #endif
   30 }