Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using utf-8 characters in log4cxx

I need to be able to use utf-8-encoded strings with log4cxx. I can print the strings just fine with std::cout (the characters are displayed correctly). Using log4cxx, i.e. putting the strings into the LOG4CXX_DEBUG() macro with a ConsoleAppender will output "??" instead of the special character. I found one solution:

LOG4CXX_DECODE_CHAR(logstring, str);
LOG4CXX_DEBUG(logstring);

where str is my input string, but this does not work. Anyone have an idea how this might work? I google'd around a bit, but I couldn't find anything useful.

like image 635
arne Avatar asked Dec 19 '12 17:12

arne


1 Answers

You can use

setlocale(LC_CTYPE, "UTF-8");

to set only the character encoding, without changing any other information about the locale.

like image 133
Brian Campbell Avatar answered Oct 05 '22 23:10

Brian Campbell