Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is unicode a reasonable default for log4cplus #1791

Closed
ngrodzitski opened this issue May 31, 2020 · 3 comments
Closed

Is unicode a reasonable default for log4cplus #1791

ngrodzitski opened this issue May 31, 2020 · 3 comments
Labels
question Further information is requested

Comments

@ngrodzitski
Copy link
Contributor

By default the recipie for log4cplus uses unicode characters.
Is this is a deliberate choice? IMO, ordinary character set must be a default option.

@SSE4
Copy link
Contributor

SSE4 commented Jun 1, 2020

I don't see any reason why Unicode shouldn't be a default in 2020. supporting multiple languages and scripts is somewhat absolutely common right now, and it's very easy to encounter characters from foreign languages due to the globalization.

@SSE4 SSE4 added the question Further information is requested label Jun 1, 2020
@ngrodzitski
Copy link
Contributor Author

ngrodzitski commented Jun 1, 2020

Well the problem is that with unicode enabled it uses only wstring and messages with std::strings becomes unacepted.

Examining libs:

$ readelf -Ws path_no_unicode/liblog4cplus.a | c++filt -n | fgrep "log4cplus::Logger::log"
   100: 0000000000000610    27 FUNC    GLOBAL DEFAULT   14 log4cplus::Logger::log(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, int, char const*) const
   102: 0000000000000660    10 FUNC    GLOBAL DEFAULT   14 log4cplus::Logger::log(log4cplus::spi::InternalLoggingEvent const&) const

$ readelf -Ws path_with_unicode/liblog4cplus.a | c++filt -n | fgrep "log4cplus::Logger::log"
   100: 0000000000000610    27 FUNC    GLOBAL DEFAULT   14 log4cplus::Logger::log(int, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&, char const*, int, char const*) const
   102: 0000000000000660    10 FUNC    GLOBAL DEFAULT   14 log4cplus::Logger::log(log4cplus::spi::InternalLoggingEvent const&) const

So in the exclusive-condition case (only chars or only wchars) is it still a better option to select unicode only?

@SSE4
Copy link
Contributor

SSE4 commented Jun 1, 2020

I understand, but if project doesn't support enabling both std::wstring and std::string simultaneously you only have two choice:

  1. use std::string, this means no Unicode on certain platforms (e.g. Windows), also you'll need to convert from std::wstring to std::string when passing strings from system APIs to log4cplus (and vice versa)
  2. use std::wstring, this means convert from std::string to std::wstring when passing strings from system APIs to log4cplus (and vice versa).

the option 2) sounds like a better default. for your project you always may override defaults (e.g. by using log4cplus:unicode=False. you also may leverage per-system profiles (using std::string on Linux, std::wstring on Windows).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants