On 18.04.2013 04:51, jorge ivan poot diaz wrote:
Hello,
Thanks you,  I have already changed the string as you said me. This is the
result:
::rtl::OUString aName ( aEdtName.GetText() );

And then I put this code

std::stringstream aStrStream;
             aStrStream << "\nThis is " << aName << " and " << aName << "
genial!" <<std::endl;
             _STL::cout << aStrStream.str();

The building was successful, but does not print whole aStrStream. Only this
part:
This is
http://imagebin.org/254440

OUString is a UTF-16 string. That means that when it is created from an ASCII string then every second byte is '\0'. That means that

            aStrStream << "\nThis is " << aName << ...

is basically equivalent to

            aStrStream << "\nThis is " << '\0' << ...

Therfore everything after "\nThis is " is cut off.  To fix this you have to 
replace
<< aName <<

with

  << ::rtl::OUStringToOString(aName, RTL_TEXTENCODING_ASCII_US).getStr() <<

You may want to use a small method to make this more readable:

  namespace
  {
      sal_Char* o2a (const ::rtl::OUString& rsText)
     {
return ::rtl::OUStringToOString(rsText, RTL_TEXTENCODING_ASCII_US).getStr();
     }
  }

and then

    aStrStream << "\nThis is " << o2a(aName) << ...

[I did not compile this, there may be typos in this]



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@openoffice.apache.org
For additional commands, e-mail: dev-h...@openoffice.apache.org

Reply via email to