[ https://issues.apache.org/jira/browse/LOGCXX-399?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13969295#comment-13969295 ]
jeong heon commented on LOGCXX-399: ----------------------------------- In my case, character set is "korean", and the [converted] bytes different from the real converted multibyte characters. For example, I wan't log "한글은? hey? 그리고". It's 0x13 bytes. But the [converted] bytes returned by mbsrtowcs was 0x0d. Then I modified the "in.position(in.position() + converted);" to "in.position(in.position() + requested);" Thanks :) > 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 > 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 (v6.2#6252)