本文介绍了PHP中的字符编码问题在Outlook中生成vCard的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们遇到了尝试在PHP中创建vcards的字符编码问题。

We're encountering character encoding issues trying to create vcards in PHP.

在使用特殊字符的Outlook名称中,é变成é 。

In Outlook names that use special characters are distorted, like "é" becomes "é".

我们更新了标题,FN和N部分的Windows字符编码,但问题仍然存在。

We updated the header and the FN and N sections for Windows character encoding, but the issue remains.

感谢任何建议。

Vcard节选:

BEGIN:VCARD
VERSION:3.0
REV:2013-03-27 19:37:46
FN;CHARSET=Windows-1252:Namé S. Nameé
N;CHARSET=Windows-1252:Namé;Namé;;;
TITLE:Associate
ORG:Company
EMAIL;TYPE=internet,pref:[email protected]
TZ:-0400
END:VCARD

Vcard的PHP标头:

PHP Header for Vcard:

    header("Content-type: text/x-vcard; charset=windows-1252;");
    header("Content-Length: ".strlen($vc->card));
    header("Content-Disposition: attachment; filename=".$vcard_name.".vcf");
    header("Pragma: public");


推荐答案

在Windows上有搞笑字符。

Your solution didn't work for me, I still got funny characters on Windows.

对我有用的是使用ISO-8859-1。您可以使用在PHP中将UTF8转换为ISO-8859-1,并使用 ENCODING = iso-8859-1 在相关字段的Vcard,使其工作在我测试的大多数基于UTF-8的客户端。

What worked for me was using ISO-8859-1 instead. You can convert UTF8 to ISO-8859-1 in PHP using utf8-decode() , and by using ENCODING=iso-8859-1 in the Vcard for the relevant fields makes it work on most UTF-8 based clients I have tested on.

标题:

Content-Type: text/x-vcard; charset=iso-8859-1

Vcard示例:

N;CHARSET=iso-8859-1:Göteborg

在Windows,OS X,IOS和Android上测试。

Tested on Windows, OS X, IOS and Android.

这篇关于PHP中的字符编码问题在Outlook中生成vCard的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 15:49