Reading UTF-8 text files with ReadList

后端 未结 2 456
攒了一身酷
攒了一身酷 2021-01-13 03:25

Is it possible to use ReadList to read UTF-8 (or any other) encoded text files using ReadList[..., Word], or is it ASCII-only? If it\'s ASCII-only

2条回答
  •  说谎
    说谎 (楼主)
    2021-01-13 04:10

    If I leave out Word, this works:

    $CharacterEncoding = "UTF-8";
    
    ReadList["UTF8.txt"]
    

    This however is a failure, because the data is not read as strings.

    Please try this on a larger file and report its performance:

    FromCharacterCode[BinaryReadList["UTF8.txt"], "UTF-8"]
    

提交回复
热议问题