On 26.04.2011 08:07, Rohit Kulkarni wrote:
How do I convert OUString to normal const char * in .cxx file.
Because I am using ldap_open(const char*,int) function which has const
char* as parameter.

On 2011/04/26 16:46, Mathias Bauer wrote:
rtl::OUString objects contain UniCode strings. If you want to convert them to a 
char* you need to provide an encoding that shall be used, e.g. 
RTL_TEXTENCODING_UTF8. With this encoding you can do it this way:

const char* p = rtl::OString(
    myOUString.getStr(), myOUString.getLength(),
    RTL_TEXTENCODING_UTF8 ).getStr();

And the same as what Mathias suggests:
 http://hg.services.openoffice.org/DEV300/file/tip/sal/rtl/source/debugprint.cxx
 http://hg.services.openoffice.org/DEV300/file/tip/sal/osl/all/utility.cxx
 http://hg.services.openoffice.org/DEV300/file/tip/sal/inc/sal/types.h

Those functions and methods might also be useful when you want print the string 
in your debugger.

To learn about OUString, look into sal/inc/rtl/ and sal/rtl/source/

Regards,
Tora
--
-----------------------------------------------------------------
To unsubscribe send email to dev-unsubscr...@openoffice.org
For additional commands send email to sy...@openoffice.org
with Subject: help

Reply via email to