![如何在 Windows 10 下的 LibreOffice 中将 unicode-8 设置为默认值?](https://linux22.com/image/1496658/%E5%A6%82%E4%BD%95%E5%9C%A8%20Windows%2010%20%E4%B8%8B%E7%9A%84%20LibreOffice%20%E4%B8%AD%E5%B0%86%20unicode-8%20%E8%AE%BE%E7%BD%AE%E4%B8%BA%E9%BB%98%E8%AE%A4%E5%80%BC%EF%BC%9F.png)
当我使用 LibreOffice Calc 并将文件保存为 .csv 时,LibreOffice 建议使用西欧作为默认编码。但是我想要 unicode-8 编码。
如何在 Windows 10 下的 LibreOffice 中将 unicode-8 设置为默认值?
答案1
查看我的 LibreOffice v5.0.x 副本,它似乎没有默认设置。不过,我四处寻找,找到了一个宏示例,您可以在此处使用它来以 UTF8 保存,
https://forum.openoffice.org/en/forum/viewtopic.php?f=45&t=19695
另一个宏告诉你使用文件选择器对话框
https://forum.openoffice.org/en/forum/viewtopic.php?f=25&t=36441
这是完整的代码...
Function fOpenFile() as String
Dim oFileDialog as Object
Dim iAccept as Integer
Dim sPath as String
Dim InitPath as String
Dim oUcb as object
Dim filterNames(3) as String
filterNames(0) = "*.csv"
'filterNames(1) = "*.png"
'filterNames(2) = "*.jpg"
GlobalScope.BasicLibraries.LoadLibrary("Tools")
'Note: The following services must be called in the following order,
' otherwise the FileDialog Service is not removed.
oFileDialog = CreateUnoService("com.sun.star.ui.dialogs.FilePicker")
oUcb = createUnoService("com.sun.star.ucb.SimpleFileAccess")
AddFiltersToDialog(FilterNames(), oFileDialog)
'Set your initial path here!
InitPath = ConvertToUrl("C:\")
If oUcb.Exists(InitPath) Then
oFileDialog.SetDisplayDirectory(InitPath)
End If
iAccept = oFileDialog.Execute()
If iAccept = 1 Then
sPath = oFileDialog.Files(0)
fOpenFile = sPath
End If
oFileDialog.Dispose()
End Function
Sub SaveAsCsvUTF8
Dim Propval(1) as New com.sun.star.beans.PropertyValue
Propval(0).Name = "FilterName"
Propval(0).Value = "Text - txt - csv (StarCalc)"
Propval(1).Name = "FilterOptions"
' field sep(44 - comma), txt delim (34 - dblquo), charset (0 = system, 76 - utf8), first line (1 or 2)
Propval(1).Value = "44,34,76,1"
Doc = ThisComponent
Filename = fOpenFile()
FileURL = convertToURL(FileName)
Doc.StoreAsURL(FileURL, Propval())
End Sub
将其分配给快捷方式就可以了。
PS:如果文件已经是UTF8格式,就应该尊重这一点。
高血压