在iCal文件中编码换行符 [英] Encoding newlines in iCal files

查看:94
本文介绍了在iCal文件中编码换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找出如何在iCal文件的Description部分编码换行符,以使它们可以正确导入Outlook,Google Calendar和Apple Calendar.

I'm trying to figure out how to encode newlines in the DESCRIPTION part of an iCal file in such a way that they will import properly into Outlook, Google Calendar and the Apple Calendar.

我继承的原始代码使用带引号可打印编码的"= 0D = 0A",在Outlook中效果很好,但在Google日历中效果不佳.

The original code I inherited used "=0D=0A" with a quoted-printable encoding, which works great in Outlook, but not in Google Calendar.

规范似乎说您应该使用"\ n"代表换行符.这在Google日历中效果很好,但是Outlook只是在其中放置了文字"\ n"字符.

The spec seems to say you should use "\n" to represent a newline. This works great in Google Calendar, but Outlook just puts the literal "\n" characters in there.

您是否有一种方法可以在日历系统中一致地工作?

Is there a way you've done this that will work consistently accross calendaring systems?

推荐答案

好的,看来我在回答自己的问题.

OK, looks like I'm answering my own question.

正确的方法是使用"\ n"作为换行符. Outlook无法识别此内容,因为我在说明中使用了"ENCODING = quoted-printable".删除该行后,Outlook会正确显示新行.

The correct way to do it is to use "\n" for line breaks. Outlook did not recognize this because I had "ENCODING=quoted-printable" on the description. Once I removed that, Outlook displayed the new lines correctly.

此外,要使文件在Apple iCal中正确打开,您需要使用"VERSION:2.0"作为文件版本.如果您使用"VERSION:1.0",它将告诉您无法读取文件(即使它符合1.0规范).

Also, to get the file to open correctly in Apple iCal, you need to use "VERSION:2.0" for the file version. If you use "VERSION:1.0", it will tell you it can't read the file (even though it conforms to the 1.0 spec).

注意:正如其他人提到的那样,文件实际上必须包含文字字符串\n.由于大多数语言将其视为表示换行符的转义序列,因此您可能需要在代码中使用字符串\\n.

NOTE: As others have mentioned, the file actually has to contain the literal string \n. Since most languages treat that as an escape sequence meaning a newline character, you probably need to use the string \\n in your code.

这篇关于在iCal文件中编码换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆