WinJS中的System.Text.Encoding
没有严格的等价 System.Text.Encoding.UTF8.GetString
在 WinJS
中,你可以尝试实现文件读取到字符串,如下所示:
file.openReadAsync.done(function (stream) {
var blob = MSApp.createBlobFromRandomAccessStream(file.contentType, stream);
var reader = new FileReader();
reader.onload = function(event) {
var fileAsText = event.target.result;
};
reader.readAsText(blob, 'UTF-8');
});
大多数情况下,( 。通过XHR上传文件,显示文件) 不需要将文件内容作为文本,所以只需使用 Blob
即可。