我当前正在阅读这样的文件:
dir := FileSystem disk workingDirectory.
stream := (dir / 'test.txt' ) readStream.
line := stream nextLine.
当文件采用 utf-8
编码时,此方法有效,但我无法找出当文件具有其他编码时该怎么做。
最佳答案
对于 Pharo 7,有这个 guide for file streams ,其中建议:
('test.txt' asFileReference)
readStreamEncoded: 'cp-1250' do: [ :stream |
stream upToEnd ].
关于smalltalk - 在 Pharo/Smalltalk : How to read a file with a specific encoding?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49492769/