How can I read a large UTF-8 file on an iPhone?

前端 未结 4 1541
谎友^
谎友^ 2021-02-13 22:31

My app downloads a file in UTF-8 format, which is too large to read using the NSString initWithContentsOfFile method. The problem I have is that the NSFileHan

4条回答
  •  没有蜡笔的小新
    2021-02-13 23:18

    utf8 is self synchronizing - just read a little more or less as needed, then read the byte values to determine the boundaries for any code point.

    also, you could use fopen and use a small, manageable buffer on the stack for this and memory will not be an issue.

提交回复
热议问题