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

Non-ascii character output wrong.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 0.10.0, 0.11.0
    • None
    • Appender
    • Windows chinese

    Description

      void main()
      {
      setlocale(LC_ALL, "");
      ...
      LOG4CXX_INFO(pLog, "一二"); // log 2 chinese characters.
      }

      Log 2 Chinese characters but output 3 characters.

      This error is caused by MbstowcsCharsetDecoder::decode().

      size_t converted = mbsrtowcs(...
      if (converted == (size_t) -1)

      { ... } else { stat = append(out, buf); in.position(in.position() + converted); // ERROR! }

      mbsrtowcs() returns the number of wide char. In case of Chinese character, position should increase 2*converted.

      My patch:

      if (converted == (size_t) -1) { ... }

      else

      { stat = append(out, buf); // in.position(in.position() + converted); // ERROR! if (src) in.position(src - in.data()); else // mbsrtowcs() set src to NULL. in.position(in.position() + strnlen(in.current(), in.remaining())); }

      Attachments

        Issue Links

          Activity

            People

              carnold@apache.org Curt Arnold
              jinq0123 Jin Qing
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 4h
                  4h
                  Remaining:
                  Remaining Estimate - 4h
                  4h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified