Utf 8 如何在LibreOffice中编写UFT8编码文件?

Utf 8 如何在LibreOffice中编写UFT8编码文件?,utf-8,libreoffice,Utf 8,Libreoffice,我想用libreofficebasic编写一个UFT8编码的文本文件 这里的示例显示了常规文本书写的使用 Filename = "c:\temp\text.html" FileNo = Freefile Open Filename For Output As #FileNo Print #FileNo, "<html><body>" 根据调查结果,文档内容将写入文本HTML文件 但是,不会写入Unicode字符。是否可以启用UFT8字符写入?一个解决方法是

我想用libreofficebasic编写一个UFT8编码的文本文件

这里的示例显示了常规文本书写的使用

 Filename = "c:\temp\text.html"
 FileNo = Freefile
 Open Filename For Output As #FileNo   
 Print #FileNo, "<html><body>"
根据调查结果,文档内容将写入文本HTML文件


但是,不会写入Unicode字符。是否可以启用UFT8字符写入?

一个解决方法是首先将所有Unicode字符转换为NCR。那么,PRINT命令不处理Unicode就无关紧要了

' search and replace Unicode values with NCRs (Numerical Character References)
' http://en.wikipedia.org/wiki/NCR

Dim oDoc,aFind,aReplace,aRayCount,oFandR

    oDoc = thisComponent

    aFind = Array("Ɛ","ɛ","Ɔ","ɔ","Ŋ","ŋ")
    aReplace = Array("&#x190;","&#x25B;","&#x186;","&#x254;","&#x14A;","&#x14B;")
    index = 0

    oFandR = oDoc.createReplaceDescriptor
    oFandR.SearchCaseSensitive = true
    oFandR.SearchRegularExpression = false
    While index <= uBound(aFind)
        oFandR.setSearchString(aFind(index))
        oFandR.setReplaceString(aReplace(index))
        index = index + 1
        oDoc.ReplaceAll(oFandR)
    Wend
End Sub
'搜索Unicode值并将其替换为NCR(数字字符引用)
' http://en.wikipedia.org/wiki/NCR
暗奥多克、阿芬德、阿雷莱斯、阿雷克斯、奥法德
oDoc=该组件
aFind=数组(“Ɛ”、“ɛ”、“Ɔ”、“ɔ”、“Ŋ”、“ŋ”)
aReplace=Array(“Ɛ;”、“ɛ;”、“Ɔ;”、“ɔ;”、“Ŋ;”、“ŋ;”)
索引=0
OFADR=oDoc.createReplaceDescriptor
OFADR.SearchCaseSensitive=true
OFADR.SearchRegularExpression=false
While索引
' search and replace Unicode values with NCRs (Numerical Character References)
' http://en.wikipedia.org/wiki/NCR

Dim oDoc,aFind,aReplace,aRayCount,oFandR

    oDoc = thisComponent

    aFind = Array("Ɛ","ɛ","Ɔ","ɔ","Ŋ","ŋ")
    aReplace = Array("&#x190;","&#x25B;","&#x186;","&#x254;","&#x14A;","&#x14B;")
    index = 0

    oFandR = oDoc.createReplaceDescriptor
    oFandR.SearchCaseSensitive = true
    oFandR.SearchRegularExpression = false
    While index <= uBound(aFind)
        oFandR.setSearchString(aFind(index))
        oFandR.setReplaceString(aReplace(index))
        index = index + 1
        oDoc.ReplaceAll(oFandR)
    Wend
End Sub