在我的應用程序中,在iOS中創建.txt文件時' n'不起作用
我以編程方式創建.txt文件。文件創建成功。但\ n在此文件中不起作用。
我爲此使用了以下代碼。
NSString *str=[NSString stringWithFormat: @"line 1 \nline 2 \nline 3"];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *pdfPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.txt",@"REFINESEARCH"]];
[str writeToFile:pdfPath atomically:YES];
當我在mac中打開REFINESEARCH.txt文件時,它將正常工作。 但是,當我在Windows操作系統中打開此文件。它看起來像這樣..
\ n在這裏不工作。 如何解決這個問題?
記事本使用什麼編碼? –
試試吧,用
替換\ n。 –
適用於HTML。這裏我沒有創建任何HTML文件。 – ChandreshKanetiya