从 DBF 中检测编码
我想自动检测DBF的编码,但DBF文件的结构不包含DBF文件头中的任何信息。我曾经使用 DBF 查看器,它会以正确的编码信息打开。所以我不确定他们是如何实现的。
我研究了 DBF 文件的结构,有一个语言驱动程序 ID,但我们没有 CodePage 表的 ID,有人知道吗?
I want to detect the encoding of DBF automatically, but the structure of DBF file doesn't contains any information in the header of DBF file. I used to use a DBF Viewer and it opens with a proper encoding information. So I'm not sure how they implement it.
I researched the structure of DBF file and there is a language driver id, but we don't have an ID to CodePage table, any one have clue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我做了很多研究,在Esri的官网上找到了这篇文章:
http://webhelp.esri.com/arcpad/8.0 /referenceguide/index.htm#locales/task_code.htm
这对我从语言 id 转换为代码页确实很有帮助;我这个问题已经解决了。希望它对其他人有帮助。
I did a lot of research and found this article in Esri's official website:
http://webhelp.esri.com/arcpad/8.0/referenceguide/index.htm#locales/task_code.htm
It really helps for me to convert from language id to code page; I this issue is fixed. Hope it helps others.
我也发现这个网站的标题结构细分为获取代码页信息。
因此,结合其他答案可能会帮助您更好地解决问题。我的链接没有列出所有代码页,但确实为您提供了从 .DBF 进行检测的位置和值
。此外,Visual Foxpro 也有一些可以获取和转换的函数,但我还没有通过最新的 Visual 明确尝试可与 C# 一起使用的 Foxpro OleDB Provider。
函数是
CPDBF()
中央处理器当前()
CPCONVERT()
您可以查看 Visual Foxpro 的联机帮助以获取有关这些函数的更多详细信息。您可能必须通过使用 VFP 的 EXECSCRIPT() 调用执行标量调用来执行 C#。类似于
然后从您的连接执行上述命令的标量。
I found this site too that has the header structural breakdown to get codepage information.
So this, in conjunction with the other answer might help you better resolve. The link I had doesn't list all the codepages, but does give you where and values for detecting from a .DBF
In addition, Visual Foxpro has some functions to get and convert too, but I haven't explicitly tried via the latest Visual Foxpro OleDB Provider that can be used with C#.
The functions are
CPDBF()
CPCURRENT()
CPCONVERT()
You can check online help for Visual Foxpro to get more details on these functions. You may have to do the C# via Execute Scalar call with VFP's EXECSCRIPT() call.. something like
then from your connection, execute scalar of the command above.