[ 
https://issues.apache.org/jira/browse/LOGCXX-483?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15405521#comment-15405521
 ] 

Thorsten Schöning commented on LOGCXX-483:
------------------------------------------

{CODE}
The encoding is ISO-8859-8
[...]
log4cxx_logchar_is_utf8=1
{CODE}

So what exactly is your internal string encoding you forward to log4cxx? I've 
always thought those LOGCHAR_IS defines tell log4cxx which encoding to expect, 
so e.g. I'm just using WCHAR defines and wchar_t based Unicode strings. But 
that might be wrong, I guess it should work to tell about UTF-8 and provide 
locale dependent encoded strings, because at least in case of the console 
appender log4cxx tries to encode stuff and that encoding takes into account fi 
the current locale is UTF-8 or not. So check the following snippets and which 
chars are available at which place and the define LOG4CXX_CHARSET_UTF8, which 
is always 0 in my case for example. You need to debug which locale Transcoder 
tries to use for encoding, if any.

systemoutwriter.cpp:

{CODE}
void SystemOutWriter::write(const LogString& str) {
#if LOG4CXX_WCHAR_T_API
[...]
#endif
    LOG4CXX_ENCODE_CHAR(msg, str);
    fputs(msg.c_str(), stdout);
}
{CODE}

transcoder.h:

{CODE}
#define LOG4CXX_ENCODE_CHAR(var, src) \
std::string var;                      \
log4cxx::helpers::Transcoder::encode(src, var)
{CODE}

transcoder.cpp:

{CODE}
void Transcoder::encode(const LogString& src, std::string& dst) {
#if LOG4CXX_CHARSET_UTF8 && LOG4CXX_LOGCHAR_IS_UTF8
   dst.append(src);
#else
   static CharsetEncoderPtr encoder(CharsetEncoder::getDefaultEncoder());
   dst.reserve(dst.size() + src.size());
   LogString::const_iterator iter = src.begin();
#if !LOG4CXX_CHARSET_EBCDIC
   for(;
       iter != src.end() && ((unsigned int) *iter) < 0x80;
       iter++) {
       dst.append(1, *iter);
   }
#endif
  if (iter != src.end()) {
    char buf[BUFSIZE];
    ByteBuffer out(buf, BUFSIZE);
    while(iter != src.end()) {
      log4cxx_status_t stat = encoder->encode(src, iter, out);
      out.flip();
      dst.append(out.data(), out.limit());
      out.clear();
      if (CharsetEncoder::isError(stat)) {
        dst.append(1, LOSSCHAR);
        iter++;
      }
    }
    encoder->encode(src, iter, out);
  }
#endif  
}
{CODE}

charsetencoder.cpp:

{CODE}
CharsetEncoder* CharsetEncoder::createDefaultEncoder() {
#if LOG4CXX_CHARSET_UTF8
   return new UTF8CharsetEncoder();
#elif LOG4CXX_CHARSET_ISO88591
   return new ISOLatinCharsetEncoder();
#elif LOG4CXX_CHARSET_USASCII
   return new USASCIICharsetEncoder();
#elif LOG4CXX_LOGCHAR_IS_WCHAR && LOG4CXX_HAS_WCSTOMBS
  return new WcstombsCharsetEncoder();
#else
  return new LocaleCharsetEncoder();
#endif
}
{CODE}


> Not able to see hebrew values when logging in log4cxx
> -----------------------------------------------------
>
>                 Key: LOGCXX-483
>                 URL: https://issues.apache.org/jira/browse/LOGCXX-483
>             Project: Log4cxx
>          Issue Type: Bug
>         Environment: Linux Debian 8 32bit
>            Reporter: Giora Guttsait
>
> When logging messages with a console appender (whose output is directed to a 
> file), hebrew text is shown as weird symbols.
> It really affects out ability to debug and analyze the program output at 
> specific points, so a quick fix(if possible) would be great



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to