如何在 Windows 10 下將 unicode-8 設定為 LibreOffice 中的預設值?

如何在 Windows 10 下將 unicode-8 設定為 LibreOffice 中的預設值?

當我使用 LibreOffice Calc 並將檔案另存為 .csv 時,LibreOffice 建議將西歐作為預設編碼。然而我想要 unicode-8 編碼。

如何在 Windows 10 下將 unicode-8 設定為 LibreOffice 中的預設值?

答案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 格式,它應該尊重這一點。

華泰

相關內容