如何通过php读取Windows unicode文件并将其存储在utf-8数据库中?
当您导出注册表项时,Windows 注册表编辑器会创建 Windows Unicode (UTF-16-le) 文件。我试图找出使用 PHP 将这些文件导入 mysql 数据库的最佳方法,以便以后可以再次将它们作为 unicode 文件下载?
当我将它们导入数据库时,我使用 file_get_contents()
并将它们存储到 utf-8 列中。当我导出它们时,我首先使用 mb_convert_encoding($row['reg'], 'UTF-16') 并发出标头来下载文件。但是,当我在 Windows 中打开它们时,内容只是乱码。
关于处理这个问题的正确方法有什么想法吗?
The Windows Registry editor created Windows Unicode (UTF-16-le) files when you export a registry key. I am trying to figure out the best way to import those files into a mysql database using PHP so that they can later be downloaded as a unicode file again?
When I import them into the database I am using file_get_contents()
and just storing them into the utf-8 column. When I export them, I first use mb_convert_encoding($row['reg'], 'UTF-16')
and issue headers to have the file downloaded. When I open them in Windows, though, the content is just garbled.
Any thoughts on the proper way to handle this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想我会分享我能找到的解决方案。诀窍是使用 UTF-16LE 作为原始字符集。
Thought I would share the solution that I was able to figure out. The trick was to use UTF-16LE as the original charset.