Open GoogleCodeExporter opened 8 years ago
Will look into this issue after releasing 0.2.
Original comment by shinichi...@gmail.com
on 23 Jan 2009 at 7:41
I vote for this too! All new projects in VS9 are anyways have unicode on with
the
character type (TCHAR/wchar_t)
Original comment by lenk...@gmail.com
on 10 Jun 2009 at 4:50
Maybe you can just add a header file whose content is
#ifndef WCHAR_LOGGING_H_
#define WCHAR_LOGGING_H_
#include <wchar.h>
#include <iostream>
#include <string>
std::ostream& operator<<(std::ostream& out, const wchar_t* str) {
size_t len = wcsrtombs(NULL, &str, 0, NULL);
char* buf = (char*)malloc(len + 1);
buf[len] = 0;
wcsrtombs(buf, &str, len, NULL);
out << buf;
free(buf);
return out;
}
std::ostream& operator<<(std::ostream& out, const std::wstring& str) {
return operator<<(out, str.c_str());
}
#endif // WCHAR_LOGGING_H_
or something for this? If you think it's useful, I'll add this header file into
glog's package.
Original comment by shinichi...@gmail.com
on 30 Jul 2009 at 8:03
i've tried to use this header in my qt project and get linker error:
CMakeFiles/test.dir/myerror.cpp.o: In function
`operator<<(std::basic_ostream<char,
std::char_traits<char> >&, wchar_t const*)':
/opt/google/include/glog/logging.h:1093: multiple definition of
`operator<<(std::basic_ostream<char, std::char_traits<char> >&, wchar_t const*)'
CMakeFiles/test.dir/xmlcheckthread.cpp.o:/usr/include/QtCore/qglobal.h:1499:
first
defined here
CMakeFiles/test.dir/myerror.cpp.o: In function
`operator<<(std::basic_ostream<char,
std::char_traits<char> >&, std::basic_string<wchar_t, std::char_traits<wchar_t>,
std::allocator<wchar_t> > const&)':
/home/aeon/projects/shalficky/qt_client/wchar_log.h:19: multiple definition of
`operator<<(std::basic_ostream<char, std::char_traits<char> >&,
std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >
const&)'
CMakeFiles/test.dir/xmlcheckthread.cpp.o:/home/aeon/projects/shalficky/qt_client
/wchar_log.h:19:
first defined here
including header in logging.h gives me same result.
is there any way to resolve this problem?
Original comment by Ponimas...@gmail.com
on 22 Jan 2010 at 5:21
Ah, I think I forgot to add "inline" for the two operators.
#ifndef WCHAR_LOGGING_H_
#define WCHAR_LOGGING_H_
#include <wchar.h>
#include <iostream>
#include <string>
inline std::ostream& operator<<(std::ostream& out, const wchar_t* str) {
size_t len = wcsrtombs(NULL, &str, 0, NULL);
char* buf = (char*)malloc(len + 1);
buf[len] = 0;
wcsrtombs(buf, &str, len, NULL);
out << buf;
free(buf);
return out;
}
inline std::ostream& operator<<(std::ostream& out, const std::wstring& str) {
return operator<<(out, str.c_str());
}
#endif // WCHAR_LOGGING_H_
Please let me know if this doesn't solve your issue.
Original comment by shinichi...@gmail.com
on 28 Jan 2010 at 10:40
Issue 29 has been merged into this issue.
Original comment by shinichi...@gmail.com
on 27 May 2010 at 8:36
Ok,I try this bug-fix in my vs2008 sp1 project, and it works. well done!
Original comment by hurrican...@gmail.com
on 1 Jul 2010 at 11:54
why not merge this in the project?
Original comment by hurrican...@gmail.com
on 1 Jul 2010 at 11:55
I got a simmilar problem, with operator ==
The code suggested doesn't fix my problem...
When will google test support wchar/wstring?
I'm using VS2012 ultimate.
Original comment by leoalves...@gmail.com
on 1 Nov 2013 at 4:22
Original issue reported on code.google.com by
notquite...@gmail.com
on 21 Jan 2009 at 9:02