Uploaded image for project: 'Log4cxx'
  1. Log4cxx
  2. LOGCXX-371

When the file path for file appender in the properties file contains multibyte characters, log4cxx creates wrong file.

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 0.10.0
    • Fix Version/s: None
    • Component/s: Configurator
    • Labels:
      None
    • Environment:
      Windows XP SP2
      VC8.0SP1

      Description

      Using properties file for configurating log4cxx, the file property for FileAppender contains multibyte characters, such as Chinese characters, log4cxx creates wrong file.

      Analyse
      When log4cxx reads properties file, the contents will be converted to utf-16 as follows:

      while(in->read(buf) >= 0) {
      buf.flip();
      log4cxx_status_t stat = dec->decode(buf, output); // Calling log4cxx::helpers::ISOLatinCharsetDecoder::decode to convert each byte in buf to UTF16.
      if (stat != 0)

      { throw IOException(stat); }

      if (buf.remaining() > 0)

      { memmove(buf.data(), buf.current(), buf.remaining()); buf.limit(buf.remaining()); }

      else

      { buf.clear(); }

      }

      Because of log4cxx::helpers::ISOLatinCharsetDecoder::decode converts by each byte each time, the multibytes character is wrong after the conversion. And the file path is wrong.
      If the file path is "D:\\Temp\\中文文件夹
      STC.log" in the properties file, after converstion the file path becomes to "D:\Temp\ÖÐÎÄÎļþ¼Ð\STC.log".

        Attachments

          Activity

            People

            • Assignee:
              carnold@apache.org Curt Arnold
              Reporter:
              starwalker Starwalker
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: