2 Replies
      Latest reply on May 14, 2019 2:56 AM by 763950084
      Singro Level 1 Level 1 (0 points)

        When working with a txt parse issue, I find an odd fact that a file with size 1000*n + 1 bytes and end with a two-byte character such as a Chinese character. Read NSData from a file, convert to NSString, but failed to convert the NSString to NSData. (error: *** -[__NSCFString dataUsingEncoding:allowLossyConversion:]: didn't convert all characters)

         

        The 1001 bytes size only get 1000 bytes after reading from the file. In the meantime, if a character is added or deleted from the file, all goes fine. Does anyone get any idea for this?

         

        Demo: https://github.com/singro/TextDecodingDemo