【发布时间】:2019-01-13 11:30:24
【问题描述】:
从 Excel 导出的文本文件使用 UTF-8 编码。
需要编码 UTF-8-BOM。
我认为在代码中应该插入一行,写成这样:
Java
?xml version="1.0" encoding="UTF-8"?
Jasperreport CSV UTF-8 without BOM instead of UTF-8
或
HTML5
meta charset="utf-8"
Bad UTF-8 without BOM encoding
Sub export_data()
Dim row, column, i, j As Integer
Dim fullPath, myFile As String
fullPath = "C:\Workspace"
row = 21
column = 5
For i = 1 To column
myFile = Cells(1, i).Value + ".txt"
myFile = fullPath + "/" + myFile
Open myFile For Output As #1
For j = 2 To row
Print #1, Cells(j, i).Value
Next j
Close #1
Next i
End Sub
如何定义一行以及在哪里放置一行,它定义了编码 UTF-8-BOM? 谢谢。
【问题讨论】:
-
想知道为什么需要 BOM?你会导入到其他需要它的程序吗?
-
感谢您的帮助。是的。我需要自动生成 *.tex 文件以在 Context /Latex/ 中实现。我发现,如果插入一行: ... Const strCharset = "utf-8-bom" ... ,则文件是 ANSI 编码的。这不是解决方案,而是向前迈出一步。
-
此代码不使用 UTF-8 字符编码写入文件。它使用计算机用户当前的 ANSI 编码(很可能不是 UTF-8)。消费程序不能读取 xlsx 工作簿吗?它是一个开放标准(Open XML SpreadsheetML)。 CSV 的问题在于它会丢弃大量元数据,然后必须将这些元数据单独传达给后续读者。