Windows 中 vCard 的 UTF8 编码
我在网站上实现了 vCard。问题是特殊字符在 Windows 上无法正确解析。
我可以让它在 Mac 上正常工作,但是一旦我在 Windows(Windows 联系人)中打开 vcf,它就会变得混乱。当我在记事本中打开 vcf 时,它会正常显示字符。
我尝试了我能找到的所有 vcf 版本(2.1、3.0、4.0)。我在内容类型标头中使用了 charset-utf-8(text/x-vcard;字符集:utf-8)。我使用了 N;CHARSET=utf-8: (以及其他标签)。
一切都无济于事。
有人有解决方案吗?感谢您分享您的见解。
使用的标头:
header("Content-type: text/x-vcard; charset=utf-8");
header("Content-Disposition: attachment; filename=".$this->filename.".vcf");
header("Pragma: public");
I have implemented a vCard on a website. Problem is though that special characters are not parsed correctly on windows.
I can get it to work fine for Mac, but as soon as I open a vcf in Windows (Windows Contacts) it gets messed up. When I open the vcf in Notepad it shows the characters normally.
I tried all vcf versions I could find (2.1,3.0,4.0). I used charset-utf-8 in my content-type header (text/x-vcard; charset: utf-8). I used N;CHARSET=utf-8: (and for the other tags).
All to no avail.
Does anyone has a solution for this? Thanks for sharing your insight.
Headers used:
header("Content-type: text/x-vcard; charset=utf-8");
header("Content-Disposition: attachment; filename=".$this->filename.".vcf");
header("Pragma: public");
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
对于我来说,要使用 UTF-8 并在 Mac OS X 上可读,所有波兰字符(例如
ĘĄĆŻŹŃŁÓŚ ęąćżźńłóś
)足以切换到声明VERSION:3.0
for me to work with UTF-8 and being readable for Mac OS X all polish characters like
ĘĄĆŻŹŃŁÓŚ ęąćżźńłóś
was enough to switch to declareVERSION:3.0
使用 ISO-8859-1 应该没问题。只需确保链中的每个部分都使用该编码(.vcf 文件、.vcf 文件中的编码声明和标头)。
标头:
Vcard(例如,必须使用 iso-8859-1 编码保存):
在 Windows、OS X、IOS 和 Android 上测试。
Use ISO-8859-1 and you should be fine. Just make sure every part in the chain uses that encoding (the .vcf file, the encoding declarations in the .vcf file, and your header).
Header:
Vcard (example, must be saved with iso-8859-1 encoding):
Tested on Windows, OS X, IOS and Android.
比较了 2 个文件,其中一个来自不同的服务,而我的。看来其他服务的工作版本使用了 Content-Type: text/x-vcard;字符集=iso-8859-1。
Compared 2 files, one working from a different service and mine. It appeared that the working version from the other service used
Content-Type: text/x-vcard; charset=iso-8859-1
.要使 Outlook 导入 UTF-8 vCard,您必须打开 Outlook 选项,转到高级 > 国际选项,然后为外发电子邮件和外发 vCard 选择
UTF-8
...瞧 - 导入成功了!必须设置导出选项才能设置导入,这不是很明显吗?谢谢微软:P
To make Outlook import UTF-8 vCards you have to open Outlook options, go to Advanced > International Options and then select
UTF-8
for outgoing emails and outgoing vCards... And voila - import works!Isn't it obvious, that one has to set export options to setup import...? Thanks Microsoft :P
我发现我没有在 vCard 字段中提供
;CHARSET=utf-8
,而是提供;CHARSET=windows-1252
,这导致 vcard 在 Outlook 中正确打开2010。并不是适合所有人的解决方案,但希望这对某人有帮助。
I found that instead of supplying
;CHARSET=utf-8
in the vCard field, I instead supplied;CHARSET=windows-1252
, which resulted in the vcard opening correctly in Outlook 2010.Not a solution for everybody, but hope this helps someone.