Nothing is wrong. It is just, how Notepad++ is working. Files are actually saved as UTF-8 w/o BOM.
Whenever an ANSI-encoded text file is opened in Notepad++, editor displays its correct encoding (ANSI). However, after actually saving that file, it will be saved as UTF-8 w/o BOM, if Apply to opened ANSI files
option is checked. To verify this, one must create a new text file in the Windows Explorer, open it in Notepad++, change contents, save and reopen. It will be recognized as encoded in UTF-8 w/o BOM.
Tip: There's a fairy easy way to force Windows Notepad to always save files in UTF-8:
It requires some tweaks in Windows registry, but allows you to have all files always encoded in UTF-8, no matter, what editor you're using.
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.
Best Answer
Go to
Settings -> Preferences -> New Document/ Open Save Directory
and then in
New Document -> Encoding
checkUTF8 without BOM
You might also want to tick "Apply to opened ANSI files":