You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Thorsten Schöning (JIRA)" <lo...@logging.apache.org> on 2018/03/21 12:44:00 UTC

[jira] [Closed] (LOGCXX-399) Non-ascii character output wrong.

     [ https://issues.apache.org/jira/browse/LOGCXX-399?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Thorsten Schöning closed LOGCXX-399.
------------------------------------
    Resolution: Duplicate

This sounds like the same problem like in LOGCXX-369, only with a different solution. 2 * converted sounds more correct to me currently, though.

> Non-ascii character output wrong.
> ---------------------------------
>
>                 Key: LOGCXX-399
>                 URL: https://issues.apache.org/jira/browse/LOGCXX-399
>             Project: Log4cxx
>          Issue Type: Bug
>          Components: Appender
>    Affects Versions: 0.10.0, 0.11.0
>         Environment: Windows chinese
>            Reporter: Jin Qing
>            Assignee: Curt Arnold
>            Priority: Major
>              Labels: patch
>   Original Estimate: 4h
>  Remaining Estimate: 4h
>
> 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()));
>    }



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)