Hi Wt-Community!

I had the same problem like Jiongliang and Wim sent me the two Quick
fixes.

First of all: The fixes work fine ;-) 
But I didn't make friends with them so far...

I will try to explain my problems: 

> Quick fix 1: try WString(L"Frankf?rt") (and make sure your compiler
speaks your .cpp file's locale)
Ok for constructing WString from literals but what if you are reading
the Strings from an variable (DB, File,...)
If I am constructing WString from literals I anyway must change every
call from WString("...") to WString(L"...") :(

> Quick fix 2: try WString(tr("Frankf?rt")) and put Frankf?rt in a
message bundle
For me this is the fix that's better than the first because it is more
general. 
Nevertheless I have to change all calls from WString(x) to
WString(tr(x))...
I derived from Wt::WLocalizedStrings, did following MS-Win specific and
called WApplication::setLocalizedStrings(...):

class ConvertStrings : public Wt::WLocalizedStrings
{
protected:
  virtual bool resolveKey( const std::string& key, std::string& result )
override
  {
    if( key.empty() )
      return true;

    std::vector< wchar_t > w;
    w.resize( key.size() * sizeof( wchar_t ) * 2 );
    MultiByteToWideChar( CP_ACP, 0, key.c_str(), -1, &w[ 0 ], w.size()
);
        
    vector< char > s;
    s.resize( w.size() );
    WideCharToMultiByte( CP_UTF8, 0, &w[ 0 ], -1, &s[ 0 ], s.size(), 0,
0 );                    
                
    result = &s[ 0 ];
    return true;
  }
};

But now the problems start, because i cannot recognize if the 'key' is
already translated or not!
So following will get me in troubles:

std::string s1 = "Frankf?rt";
Wt::WString w1(tr( s )); // OK
std::string s2 = w1.narrow();
Wt::WString w2(tr( s2 )); // Bad, because s2 is already translated

So my question is: 
Is WString and it's conversion operations in the constructors ok, or am
I missing something essential?
Think about following:

std::wstring s = L"Frankf?rt";
WString x = WString(s);// now the 'utf8_' member of WString seems to be
translated
std::string s1 = x.narrow(); // now the conversion gets lost...

best regards
Max


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to