Details
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)
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
- duplicates
-
LOGCXX-369 Load Properties File Fails When There Are multibyte Characters in the Path
- Resolved
- links to