如何在 Windows 10 下的 LibreOffice 中将 unicode-8 设置为默认值?

如何在 Windows 10 下的 LibreOffice 中将 unicode-8 设置为默认值?

当我使用 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格式,就应该尊重这一点。

高血压

相关内容