Christian Waidner
Christian Waidner

Reputation: 1334

Generate UTF-8 file with NotesStream

I'm trying to export some text to an UTF-8 file with LotusScript. I checked the documentation and the following lines should output my text as UTF-8, but Notepad++ says it's ANSI.

Dim streamCompanies As NotesStream
Dim sesCurrent as New NotesSession

Set streamCompanies = sesCurrent.CreateStream
Call streamCompanies.Open("C:\companies.txt", "UTF-8")
Call streamCompanies.WriteText("Test")
streamCompanies.Close

When I try the same with UTF-16 instead of UTF-8, the generated fileformat is correct. Could anyone point me in the right direction on how to write an UTF-8 file with LotusScript on a Windows platform?

Upvotes: 1

Views: 5071

Answers (2)

Ken Pespisa
Ken Pespisa

Reputation: 22266

Notes is most likely doing its job and encoding properly. It is likely that Notepad++ is interpreting the UTF-8 file as ANSI if no UTF-8-only characters exist in the file. There is no other way to determine the encoding in this case other than to analyze its contents.

See this SO answer: How to avoid inadvertent encoding of UTF-8 files as ASCII/ANSI?

So a simple test to make sure Notes is working would be to output a non-ANSI character and then open in Notepad++ to confirm.

Upvotes: 2

Christian Waidner
Christian Waidner

Reputation: 1334

Closed - down the line while coding I stumbled across some data with Asian characters which where displayed correctly in my text editor. Rechecking file encodings I found the following:

If the output text only includes ASCII-chars, it is decoded as ANSI with Notepad++ If the output text contains e.g. Katakana, it is decoded as UTF-8 with Notepad++

-> problem solved for me.

Upvotes: 0

Related Questions