https://bugs.documentfoundation.org/show_bug.cgi?id=174133
Bug ID: 174133
Summary: TextOutputStream.setEncoding("UTF-16") fails with
"Unknown encoding 'UTF-16'" in LibreOffice 26.8, while
working in LibreOffice 25.x
Product: LibreOffice
Version: 26.8.1.1 release
Hardware: x86-64 (AMD64)
OS: Windows (All)
Status: UNCONFIRMED
Severity: normal
Priority: medium
Component: BASIC
Assignee: [email protected]
Reporter: [email protected]
After upgrading from LibreOffice 25.x to LibreOffice 26.8.0.3, BASIC macros
using UNO service com.sun.star.io.TextOutputStream can no longer write UTF-16
encoded text files.
Calling:
BASIC
oText.setEncoding("UTF-16")
now raises:
Plain Text
com.sun.star.lang.IllegalArgumentException:
Unknown encoding 'UTF-16'
The same macro worked correctly on LibreOffice 25.x.
According to the UNO API documentation, XTextOutputStream.setEncoding() should
accept IANA character set names, and UTF-16 is a standard IANA encoding.
This appears to be a regression.
Steps to Reproduce
Use the following BASIC macro:
BASIC
Sub TestUTF16
Dim oSFA As Object
Dim oText As Object
oSFA = CreateUnoService("com.sun.star.ucb.SimpleFileAccess")
oText = CreateUnoService("com.sun.star.io.TextOutputStream")
oText.setOutputStream( _
oSFA.openFileWrite("file:///C:/Temp/test.txt") )
oText.setEncoding("UTF-16")
oText.writeString("Test UTF16")
oText.closeOutput()
End Sub
Actual Result
An exception is raised:
Plain Text
com.sun.star.lang.IllegalArgumentException
Unknown encoding 'UTF-16'
Expected Result
The file should be written using UTF-16 encoding without exception.
Additional Information
The following conditions were verified:
Service used: com.sun.star.io.TextOutputStream
Output stream is correctly initialized using setOutputStream()
UTF-8 encoding works correctly:
BASIC
oText.setEncoding("UTF-8") -> Ok
The problem specifically occurs with UTF-16-related encodings.
The same code worked on LibreOffice 25.x before upgrade.
it's same with "UTF16", "UTF-16LE", "UTF-16BE","Unicode"
Version Information
LibreOffice:
Plain Text
Version: 26.8.0.3 (X86_64)
Build ID: bce0998afefdbc355585ca324285661a2170ba77
CPU threads: 16
OS: Windows 11 X86_64
UI render: Skia/Raster
Locale: fr-FR
UI: fr-FR
Worked in: LibreOffice 25.x
Fails in: LibreOffice 26.8.0.3
--
You are receiving this mail because:
You are the assignee for the bug.