 | OO-Snippets: 'Cout' an OUStrings ?Commons| Keywords | OUStrings, Strings, std, string, print, <<, cout |
|---|
| Language | Cpp |
|---|
| Application | Office |
|---|
| Authors | Pierre-André Galmes (initial)
|
|---|
| Supported Versions | 2.0.x |
|---|
| Supported OS | All |
|---|
| Question | Howto print OUStrings ?
I do want to see the content of an OUString. How do I do
to use the standard output to display it ?
|
|---|
| Answer | In fact, to print an OUString, you need to convert it in a OString. The result of the code : aouString : 0xb5b87fd8 aOString : Coucou |
|---|
#include <iostream>
#include <exception>
#include <rtl/ustring.hxx>
using namespace std;
using namespace ::rtl;
int SAL_CALL main(int argc, char **argv)
{
OUString aouString = OUString::createFromAscii( "Coucou" );
OString aOString = ::rtl::OUStringToOString ( aouString,
RTL_TEXTENCODING_UTF8);
cout << "aouString : " << aouString << endl;
cout << "aOString : " << aOString << endl;
return 0;
}
|
Changelog| Date | User | Modification |
|---|
| 2005-09-13 | pagalmes | Added the #include in the code | | 2005-09-13 | pagalmes | Initial version |
|