Menu

#309 failure to creat log file having unicode characters in its filepath

v1.2.x
open
2
2016-08-06
2014-07-16
Saood
No
  1. created a folder path for creating the log file as follows
    /Users/<someName>/私は食べに行くよ
  2. I built log4cplus 1.2.2 using the following command on OSX Mavericks
    ./configure CXX="clang++ -arch i386 -stdlib=libstdc++" --with-working-locale
  3. The following code is expected to create a log file in the specified path as shown in (1), here fileName value recieved is /Users/<someName>/私は食べに行くよ/log.txt
void LogImpl::setFile(const std::wstring &fileName)
{
  log4cplus::tstring ts;
  ts.assign(fileName.begin(), fileName.end());
  log4cplus::RollingFileAppender *rfa = new log4cplus::RollingFileAppender(ts, 
  DMLOG_MAXSIZE_PERFILE, DMLOG_MAXFILES_FORLOG);
  //...
  //...
  //...
}

4 Unfrtunately, the log file does not get created.
5. When i try the same thing with the non-unicode path, it works fine.

Can you please help me understand what mistake is being done in the above steps.

Discussion

  • Saood

    Saood - 2014-07-16

    What I noticed is log4cplus::tstring ts - this variable is failing to recognize unicode characters and replaces all unicode characters with alphanumerics as follows
    log4cplus::tstring "/Users/<someName>/\xc1o\xdfykLO\x88/test.log"

     
  • Václav Haisman

    Václav Haisman - 2014-07-19
    • labels: unicode --> unicode, osx
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,9 +1,12 @@
    -. created a folder path for creating the log file as follows 
    -/Users/<someName>/私は食べに行くよ
    -. I built log4cplus 1.2.2 using the following command on OSX Mavericks
    -./configure CXX="clang++ -arch i386 -stdlib=libstdc++" --with-working-locale
    -. The following code is expected to create a log file in the specified path as shown in (1), here fileName value recieved is = /Users/<someName>/私は食べに行くよ/log.txt
    +  1. created a folder path for creating the log file as follows 
    +`/Users/<someName>/私は食べに行くよ`
    +  2. I built log4cplus 1.2.2 using the following command on OSX Mavericks
    +`./configure CXX="clang++ -arch i386 -stdlib=libstdc++" --with-working-locale`
    +  3. The following code is expected to create a log file in the specified path as shown in (1), here fileName value recieved is `/Users/<someName>/私は食べに行くよ/log.txt`
    
    +
    +
    +~~~~
     void LogImpl::setFile(const std::wstring &fileName)
     {
     log4cplus::tstring ts;
    @@ -14,8 +17,11 @@
     ...
     ...
     }
    +~~~~
    
    -. Unfortunately, the log file does not get created.
    -. When i try the same thing with the non-unicode path, it works fine.
    +
    +
    +- Unfrtunately, the log file does not get created.
    +- When i try the same thing with the non-unicode path, it works fine.
    
     Can you please help me understand what mistake is being done in the above steps.
    
     
  • Václav Haisman

    Václav Haisman - 2014-07-19
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -2,26 +2,24 @@
     `/Users/<someName>/私は食べに行くよ`
       2. I built log4cplus 1.2.2 using the following command on OSX Mavericks
     `./configure CXX="clang++ -arch i386 -stdlib=libstdc++" --with-working-locale`
    -  3. The following code is expected to create a log file in the specified path as shown in (1), here fileName value recieved is `/Users/<someName>/私は食べに行くよ/log.txt`
    -
    +  3. The following code is expected to create a log file in the specified path as shown in (1), here `fileName` value recieved is `/Users/<someName>/私は食べに行くよ/log.txt`
    
     ~~~~
     void LogImpl::setFile(const std::wstring &fileName)
     {
    -log4cplus::tstring ts;
    -ts.assign(fileName.begin(), fileName.end());
    -log4cplus::RollingFileAppender *rfa = new log4cplus::RollingFileAppender(ts, 
    -DMLOG_MAXSIZE_PERFILE, DMLOG_MAXFILES_FORLOG);
    -...
    -...
    -...
    +  log4cplus::tstring ts;
    +  ts.assign(fileName.begin(), fileName.end());
    +  log4cplus::RollingFileAppender *rfa = new log4cplus::RollingFileAppender(ts, 
    +  DMLOG_MAXSIZE_PERFILE, DMLOG_MAXFILES_FORLOG);
    +  //...
    +  //...
    +  //...
     }
     ~~~~
    
    -
    -- Unfrtunately, the log file does not get created.
    -- When i try the same thing with the non-unicode path, it works fine.
    +  4  Unfrtunately, the log file does not get created.
    +  5. When i try the same thing with the non-unicode path, it works fine.
    
     Can you please help me understand what mistake is being done in the above steps.
    
     
  • Václav Haisman

    Václav Haisman - 2016-03-22

    Try without --with-working-locale configuration and try to use --with-working-c-locale instead.

     
  • Václav Haisman

    Václav Haisman - 2016-08-06

    I wonder if the above suggestion to use --with-working-c-locale has helped or not.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.