Re: OUString

Mathias Bauer <[email protected]> Tue, 26 Apr 2011 09:46:18 +0200
Newsgroups gmane.comp.openoffice.devel.general
Message-ID <[email protected]>
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.
>
> Regards,
> Rohit

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();

Regards,
Mathias

-- 
Mathias Bauer (mba) - Project Lead OpenOffice.org Writer
OpenOffice.org Engineering at Oracle: http://blogs.sun.com/GullFOSS
Please don't reply to "[email protected]".
I use it for the OOo lists and only rarely read other mails sent to it.
-- 
-----------------------------------------------------------------
To unsubscribe send email to [email protected]
For additional commands send email to [email protected]
with Subject: help