将 Microsoft Access 表导出为 UTF-16 CSV

发布于 2024-10-16 14:33:46 字数 388 浏览 3 评论 0原文

我有一个包含一些中文字符的 Access 表,我需要将其导出到使用 UTF-16 编码的 CSV 文件中。如果这是不可能的,我还可以尝试将表导出到 XLS 或 CSV 文件,然后将编码转换为 UTF-16。

我有一种感觉,使用 Access 和/或 Excel 和/或 VBA 没有简单的方法可以做到这一点,但如果有的话,我很想听听!如果没有,使用 Java 的解决方案会很有帮助。

我确信,如果我知道该文件已经采用的编码方式,将会很有帮助。当我将文件导出到 Microsoft Excel 2000 时,中文字符可以正确显示,但在 Microsoft Access 中却不能正确显示。它们最初被输入到 Microsoft Excel 中。我认为这意味着它们是 Unicode 富文本格式,但我不确定。

非常感谢!

I have an Access table with some Chinese characters that I need to export into a CSV file with UTF-16 encoding. If this is not possible, I could also try exporting the table into an XLS or CSV file, and then convert the encoding to UTF-16.

I have a feeling there is no simple way of doing this using Access and/or Excel and/or VBA, but if there is, I would love to hear it! If not, a solution using Java would be helpful.

I'm sure it would be helpful if I knew what encoding the file was already in. The Chinese characters show up correctly when I export the file to Microsoft Excel 2000, but they do not show up correctly in Microsoft Access. They were originally typed into Microsoft Excel. I think that means they are in Unicode rich text, but I'm not sure.

Thanks much!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

热风软妹 2024-10-23 14:33:46

我使用 ADO 流来做这类事情。我必须为大量网站执行此操作,我正在帮助他们实现 SEO 自动化。

http://www.nonhostile.com/howto-convert -byte-array-utf8-string-vb6.asp

' 接受包含 utf-8 数据的字节数组
'并将其转换为字符串
公共函数 ConvertStringToUtf8Bytes(ByRef strText As String) As Byte()

Dim objStream As ADODB.Stream
Dim data() As Byte

' init stream
Set objStream = New ADODB.Stream
objStream.Charset = "utf-16"
objStream.Mode = adModeReadWrite
objStream.Type = adTypeText
objStream.Open

' write bytes into stream
objStream.WriteText strText
objStream.Flush

' rewind stream and read text
objStream.Position = 0
objStream.Type = adTypeBinary
objStream.Read 3 ' skip first 3 bytes as this is the utf-8 marker
data = objStream.Read()

' close up and return
objStream.Close
ConvertStringToUtf8Bytes = data

结束函数

I use ADO streams to do this sort of thing. I had to do this for a TON of websites where I was helping them with SEO automation.

http://www.nonhostile.com/howto-convert-byte-array-utf8-string-vb6.asp

' accept a byte array containing utf-8 data
' and convert it to a string
Public Function ConvertStringToUtf8Bytes(ByRef strText As String) As Byte()

Dim objStream As ADODB.Stream
Dim data() As Byte

' init stream
Set objStream = New ADODB.Stream
objStream.Charset = "utf-16"
objStream.Mode = adModeReadWrite
objStream.Type = adTypeText
objStream.Open

' write bytes into stream
objStream.WriteText strText
objStream.Flush

' rewind stream and read text
objStream.Position = 0
objStream.Type = adTypeBinary
objStream.Read 3 ' skip first 3 bytes as this is the utf-8 marker
data = objStream.Read()

' close up and return
objStream.Close
ConvertStringToUtf8Bytes = data

End Function

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文