WinJS中的System.Text.Encoding

来源:互联网 发布:神话网络电话卡骗局 编辑:程序博客网 时间:2024/05/22 00:22

WinJS中的System.Text.Encoding


没有严格的等价 System.Text.Encoding.UTF8.GetStringWinJS 中,你可以尝试实现文件读取到字符串,如下所示:

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 即可。


原创粉丝点击