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

前端 未结 4 1282
谎友^
谎友^ 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:13

    One approach would be to

    1. read up to a certain point -
    2. then examine the last byte(s) to determine if it is splitting a UTF-8 character
    3. if not - read the next chunk
    4. if yes, get the next byte and fix - then read the next chunk

提交回复
热议问题