I want to change the default text encoding used by LibreOffice when saving a document as a Text document. Where can I find this setting?
I want it to be UTF-8 WITHOUT the BOM, which I believe is called ASCII/US in LibreOffice.
I do know that there is a Text encoded option where you can (in theory, if it actually worked) choose the encoding of each plain file. I have three problems with this:
- It doesn't properly work. I.e. most of the time it doesn't show any popup where you can choose the encoding and just saves as if you chose the Text option. Maybe once in ten trials it shows the popup.
- I only edit plain text files and I use LibreOffice only for spellchecking (and counting words). All the files I will ever want to write should be UTF-8 encoded without the BOM, so I'd like to avoid wasting time everytime by manually selecting this option.
- If I have a file correctly encoded in UTF-8 without the BOM, and I then try to save it using, for example, Ctrl+S then the file will be automatically saved using the Text default encoding which saves the file as UTF-8 with BOM which breaks the file. LibreOffice should preserve the encoding of the file and save the file as UTF-8 without the BOM. Having to use Save As every single time is a real waste of time.
2 Answers 2
To show the encoding options dialog, go to Save As... and check Edit filter settings.
In order to avoid the slowness of Save As..., you could use a macro like this:
Sub SaveAsUtf8
dim aUrl()
dim fileProps(1) as new com.sun.star.beans.PropertyValue
fileProps(0).Name = "FilterName"
fileProps(0).Name = "Text (encoded)"
fileProps(1).Name = "FilterOptions"
fileProps(1).Value ="UTF8,CRLF,Liberation Mono,en-US,"
oDlg = createUnoService("com.sun.star.ui.dialogs.FilePicker")
oDlg.setMultiSelectionMode(false)
oDlg.initialize(array(1))
oDlg.execute
aUrl = oDlg.getFiles()
If UBound(aUrl) > -1 Then
thisComponent.storeAsURL(aURL(0), fileProps())
End If
End Sub
Set it to a hotkey or toolbar button by going to Tools -> Customize.
It could be modified to use a global variable and save to the previously used location.
UTF-8 WITHOUT the BOM, which I believe is called ASCII/US
No, this produces ASCII-encoded text, which will destroy most Unicode characters.
I do not see any filter options that can save without a BOM from LibreOffice. Instead, there are various command line tools such as iconv that can remove the BOM.
If you have some time, the best solution may be to create a Python or Java macro to read the Writer document and write to a file without the BOM. It could be done in perhaps 30 lines of Python code, or twice that much Java code. Note: I would not recommend doing this in Basic because of its poor file handling functions.
-
1Do you have any idea why LibreOffice is going against the Unicode Standard by adding the BOM for utf-8? Quote: "Use of a BOM is neither required nor recommended for UTF-8". This makes it extremely hard to use such files with other programs (e.g. pdfLaTeX in my case).Bakuriu– Bakuriu2016年07月19日 09:19:24 +00:00Commented Jul 19, 2016 at 9:19
-
By the way, the macro you have written saves with the BOM right? So it's useless.Bakuriu– Bakuriu2016年07月19日 09:21:09 +00:00Commented Jul 19, 2016 at 9:21
-
1Yes, it does save with the BOM. As stated in the answer, you could use the macro and then run a tool such as
iconvto remove the BOM. Or, write a complete solution in Python or Java. I could do it except that this website is not a code writing service, so instead this answer points toward possible solutions.Jim K– Jim K2016年07月19日 09:46:02 +00:00Commented Jul 19, 2016 at 9:46 -
Regarding how LibreOffice is designed, I do not know the motivation behind the decision.Jim K– Jim K2016年07月19日 09:46:09 +00:00Commented Jul 19, 2016 at 9:46
Old post, problem can still occur. Fix for me in latest (2025) version 25.2.1.2 is to check "Edit Filter Settings" on the Save/Save As dialog (you must be saving as CSV). For US English on Windows 10, select "Western Europe/ASCII-US".
-
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.2025年03月06日 22:52:24 +00:00Commented Mar 6 at 22:52
-
The OP was asking about text documents. In Writer you should choose "Save as type: Text - Choose Encoding (*.txt)", instead of CSV.Velvet– Velvet2025年03月06日 22:54:41 +00:00Commented Mar 6 at 22:54
-
1This answer is enough of a guide; just telling my LibreOffice to "Edit filter settings" and choosing UTF-8 solved my csv oddities.bgStack15– bgStack152025年03月31日 19:28:48 +00:00Commented Mar 31 at 19:28
You must log in to answer this question.
Explore related questions
See similar questions with these tags.