When I try to convert a NSString object into a NSdata object, I use the following code:
NSString *finalWordList = wordList.text;
NSData *data = [finalWordList dataUsingEncoding:NSUTF8StringEncoding];
wordList is a UITextView object.
After that, I upload the NSdata object to my web server, which will be in .txt format. When I check the file, I notice that the \n character is missing in the uploaded txt file. Does anyone know why?
Any kind of help would be appreciated.
I think I know the answer. It is because of the difference in operating system.
For iphone OS, \n means a new line. But for the display in windows notepad, a “\r” is also needed, i.e. “\r\n”, such that it can display the new line character.