Giter VIP home page Giter VIP logo

Comments (9)

GoogleCodeExporter avatar GoogleCodeExporter commented on August 16, 2024
Will look into this issue after releasing 0.2.

Original comment by [email protected] on 23 Jan 2009 at 7:41

  • Changed state: Accepted

from google-glog.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 16, 2024
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 [email protected] on 10 Jun 2009 at 4:50

from google-glog.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 16, 2024
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 [email protected] on 30 Jul 2009 at 8:03

from google-glog.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 16, 2024
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 [email protected] on 22 Jan 2010 at 5:21

from google-glog.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 16, 2024
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 [email protected] on 28 Jan 2010 at 10:40

from google-glog.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 16, 2024
Issue 29 has been merged into this issue.

Original comment by [email protected] on 27 May 2010 at 8:36

from google-glog.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 16, 2024
Ok,I try this bug-fix in my vs2008 sp1 project, and it works. well done!

Original comment by [email protected] on 1 Jul 2010 at 11:54

from google-glog.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 16, 2024
why not merge this in the project?

Original comment by [email protected] on 1 Jul 2010 at 11:55

from google-glog.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 16, 2024
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 [email protected] on 1 Nov 2013 at 4:22

from google-glog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.