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 18:40:00 UTC

[jira] [Resolved] (LOGCXX-369) Load Properties File Fails When There Are multibyte Characters in the Path

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

Thorsten Schöning resolved LOGCXX-369.
--------------------------------------
       Resolution: Fixed
    Fix Version/s: 0.11.0

I fixed this using "requested" like mentioned in LOGCXX-399 and the linked PR #4 on GitHub. Additionally I added a test "decodingtest" using "encodingtest" as template, but the problem didn't occur using my C++Builder because I lack the used API, so am not sure if that works at all. It didn't fail before and doesn't now, so in the worst case is simply not doing anything useful. ;-)

> Load Properties File Fails When There Are multibyte Characters in the Path
> --------------------------------------------------------------------------
>
>                 Key: LOGCXX-369
>                 URL: https://issues.apache.org/jira/browse/LOGCXX-369
>             Project: Log4cxx
>          Issue Type: Bug
>          Components: Configurator
>    Affects Versions: 0.10.0
>         Environment: Windows XP SP2
> VC8.0SP1
>            Reporter: Starwalker
>            Assignee: Thorsten Schöning
>            Priority: Major
>             Fix For: 0.11.0
>
>
> Load properties file fails when calling PropertyConfigurator::configure using a MBCS string which type is char * or std::string and contains multibyte characters, such as Chinese characters.
> Analyse
> When calling PropertyConfigurator::configure using a MBCS string which type is char * or std::string, the constructor of File will call Transcoder::decode to convert MBCS string to DBCS string. When meets the byte which is greater than or equal to 0x80, the function will call MbstowcsCharsetDecoder::decode to process the following characters. But there is an error in MbstowcsCharsetDecoder::decode when calculating the offset after calling mbsrtowcs.
> size_t converted = mbsrtowcs(buf,       // This function returns the number of wide characters, maybe not equal to the number of the bytes of multibyte characters
>     &src,
>     requested,
>     &mbstate);
> if (converted == (size_t) -1) {
>     stat = APR_BADARG;
>     in.position(src - in.data());
>     break;
> } else {
>     stat = append(out, buf);
>     in.position(in.position() + converted);    // Here, the number of the bytes of multibyte characters should be added, not the number of wide characters
> }
> The path "D:\Temp\中文文件夹\STC\Config\Log.properties" becomes "D:\Temp\中文文件夹\STC\Config\Log.propertiesrties" after convertion.
> There are 10 bytes for the 5 Chinese characters, but only 5 wide characters. Because the error above, last 5 characters repeated.



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