gcc - How to make String to const wchar_t* conversion function work under Windows and Linux -


I work on a project written for MSVCC / Windows, that I have a port on GCC / Linux String class, which stores its data in Qstrung from QT. Originally this method (for Windows) for the conversion of Wchar_t was:

  const wchar_t * string :: c_str () const {if (length ()> gt) {return (const wchar_t) *) QString :: Unicode (); } And {return & amp; S_nullString; }}  

Because the QCode (which is 16 bit long), it works under Windows because wchar_t is 16 bit but now the GCC is 32 bit long with wchar_t, so She does not work anymore. I have tried to solve it:

  const wchar_t * string :: c_str () const {if (isEmpty ()) {return & amp; S_nullString; } And {return toStdWString () C_str (); }}  

With this problem, this object is no longer functional, so this eater does not work. I think the only way to solve this issue is either:

  1. Do not use string: c_str () and call .toStdString (). C_str () directly
  2. Treat GCC as a 16-bit type in the form of GCC

The probability one means to mean several hours of work without me And I do not know if probability 2 is possible. My question is, how do I solve this issue best? I appreciate any useful tips thanks.

In my opinion, there are 2 ways:

  1. wert_t to QSTring Change in * When it is needed
  2. Allow Qestring to be wchar_t * Store and Qestring :: Unicode directly back

These two functions are used for QString: std :: string And std :: wstring

To make the QoString as ucs4:

  #define QT_QSTRING_UCS_4 #include "qstring.h"  

It can be used in qt3 () I can not find the source of QT4 Yes.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -