Fwd: Re: offline help replacement

Tomaž Vajngerl quikee at gmail.com
Sat Dec 23 14:47:51 UTC 2017


Hi,

On Sat, Dec 23, 2017 at 7:13 PM, Olivier Hallot
<olivier.hallot at libreoffice.org> wrote:
> HI
>
> Newbie seeking advice!
>
> I am trying to implement Kendy's idea of a temp file with some HTML
> inside, I seek a piece of code to open a temp file, write contents in
> it, close it.
>
> I started with
> ---------------
>     OUString aExtension(".html");
>     ::utl::TempFile aTempFile("newhelp", true, &aExtension, nullptr,
> false );
>     aTempFile.EnableKillingFile();
> --------------
>
> But then How do I write a simple OUString ("hello world") inside it?

continued from your example...

SvStream* pStream = aTempFile.GetStream(StreamMode::WRITE);
pStream->SetStreamCharSet(RTL_TEXTENCODING_UTF8);
pStream->WriteUnicodeOrByteText(OUString ("hello world"));
pStream->Close();
aTempFile.CloseStream();

As you can see this converts the OUString to UTF8 when you write it.
BTW. I didn't try to compile this, so it may be wrong :)

> Thanks in advance.
> Seasons Greetings!
> Olivier

Best Regards,
Tomaž


More information about the LibreOffice mailing list