English 中文(简体)
Save BOM with file
原标题:Save BOM with File

难道有人要告诉我,如何用档案来挽救 by令标记? 例如,现在我只保存一个文本文件:

NSString *currentFileContent = @"This is a string of text to represent file content.";
NSString *currentFileName = @"MyFileName";
NSString *filePath = [NSString stringWithFormat:@"%@/%@.%@", [self documentsDirectory], currentFileName, rtf];
[currentFileContent writeToFile:filePath atomically:YES encoding:NSUTF16StringEncoding error:&error];

My understanding of BOM is:

The BOM character is the "ZERO WIDTH NO-BREAK SPACE" character, U+FEFF, in the Unicode character set.

I have an iPhone application that allows users to save text to an RTF file. All works fine if I use NSUTF8StringEncoding, unless the user has double-byte characters such as Japanese, or Chinese. The simple answer would seem to be saving the file with NSUTF16StringEncoding which is allowed in more recent RTF specs, except that Microsoft Word can only automatically open UTF-16 files if a BOM is defined.

我希望,如果我能够建立一个通用的管理局,我就没有必要确定用户的特性,因为我无法知道什么是事先的。 但是,他们仍然能够以双重特点打开区域工作队的档案。

感谢建议或见解。

最佳回答

如果你先将插图转换成数据,然后将数据输入存档,那么,国家统计局将添加<条码>数据编码:allowLossyConversion:,将给你增加管理局。 你可以撰写以下文件:

NSData *data = [currentFileContent dataUsingEncoding:NSUTF16StringEncoding];
[data writeToFile:filePath options:NSDataWritingAtomic error:&error];
问题回答

暂无回答




相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签