Date: prev next · Thread: first prev next last
2018 Archives by date, by thread · List index

I just checked OOME 4, and I think that I have a glaring omission in that I do not test or document the behavior of using write or print with special characters. Sadly, I do not know the answer off hand, but, I expect that you are seeing that they are not properly supported.

Can you try using Simple File Access instead and let me know if that works?

There is an example her:

I include the example here, but, you should be able to see what you need to do. Also note that the ODT documents contains the macros and you can run the test program while reading the document if you eneable macros when you load the document.

This is the example macro:

Sub ExampleSimpleFileAccess
  Dim oSFA        ' SimpleFileAccess service.
  Dim sFileName$  ' Name of file to open.
  Dim oStream     ' Stream returned from SimpleFileAccess.
  Dim oTextStream ' TextStream service.
  Dim sStrings    ' Strings to test write / read.
  Dim sInput$     ' The string that is read.
  Dim s$          ' Accumulate result to print.
  Dim i%          ' Index variable.

  sStrings = Array("One", "UTF:Āā", "1@3")

  ' File to use.
  sFileName = CurDir() & "/delme.out"

  ' Create the SimpleFileAccess service.
  oSFA = CreateUnoService("")

  'Create the Specialized stream.
  oTextStream = CreateUnoService("")

  'If the file already exists, delete it.
  If oSFA.exists(sFileName) Then
  End If

  ' Open the file for writing.
  oStream = oSFA.openFileWrite(sFileName)

  ' Attach the simple stream to the text stream.
  ' The text stream will use the simple stream.

  ' Write the strings.
  For i = LBound(sStrings) To UBound(sStrings)
    oTextStream.writeString(sStrings(i) & CHR$(10))

  ' Close the stream.

  oTextStream = CreateUnoService("")
  oStream = oSFA.openFileRead(sFileName)
  For i = LBound(sStrings) To UBound(sStrings)
    sInput = oTextStream.readLine()
    s = s & CStr(i)

    ' If the EOF is reached then the new line delimiters are
    ' not removed. I consider this a bug.
    If oTextStream.isEOF() Then
      If Right(sInput, 1) = CHR$(10) Then
        sInput = Left(sInput, Len(sInput) - 1)
      End If
    End If

    ' Verify that the read string is the same as the written string.
    If sInput <> sStrings(i) Then
      s = s & " : BAD "
      s = s & " : OK "
    End If
    s = s & "(" & sStrings(i) & ")"
    s = s & "(" & sInput & ")" & CHR$(10)
  MsgBox s
End Sub

Let me know if this works, I believe that it will. I hope that it will.

On 2018-08-30 6:06, Cédric Giraud wrote:
With the macro, *open *and *print *commands.

Le jeu. 30 août 2018 à 05:22, Andrew Pitonyak <> a
écrit :

How do you open the file and write the text?

Sent from BlueMail <>
On Aug 29, 2018, at 5:35 PM, Cegir <> wrote:

Hi, thanks for your help

I'm on Windows 10, and my keyboard is AZERTY. As French, the system is
probably not UTF-8 by default.
I just copy/paste hangul from another .ods file.
I tried with 2 text editors and the .json reader from Firefox.

It seems the problem is the macro creates an ANSI file by default, and not a
UTF-8 version. I have no idea how to change it.

If I create an UTF-8 file before running the macro, the macro recreates it
in ANSI.

Sent from:

To unsubscribe e-mail to:
Posting guidelines + more:
List archive:
Privacy Policy:


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.