FileSystemManager.readFile(Object object)
内部含有中文字符的文件时,文件内容发生乱码,文件格式UTF8,
encode utf-8,"<p class=“STYLE1” style=“background-color: transparent; color: rgb(0, 0, 0); font-family: Microsoft YaHei; font-size: 24px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;”>
�������<br/>
</p>
<p>
<img src=“https://636e-cnczhu-e54acb-1257960360.tcb.qcloud.la/������ť2.png?sign=dddae4f51654724bfccbda6d809b0e17&t=1541083939”/>
</p>
<p>
<br/>
</p>"实际文本文件内容:
<p class=“STYLE1” style=“background-color: transparent; color: rgb(0, 0, 0); font-family: Microsoft YaHei; font-size: 24px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;”>
代码测试<br/>
</p>
<p>
<img src=“https://636e-cnczhu-e54acb-1257960360.tcb.qcloud.la/帮助按钮2.png?sign=dddae4f51654724bfccbda6d809b0e17&t=1541083939”/>
</p>
<p>
<br/>
</p>
问题代码:
wx.cloud.downloadFile({
fileID: ‘cloud://cnczhu-e54acb.636e-cnczhu-e54acb/富文本测试.txt’, // 文件 ID
success: res => {
// 返回临时文件路径
console.log(res.tempFilePath)
var FileManager= wx.getFileSystemManager();
//console.log(FileManager);
FileManager.readFile({
filePath:res.tempFilePath,
encoding:‘utf8’,
success:function(data){ //成功时
console.log(‘文件内容’,data);
// WxParse.wxParse(‘aboutHtml’, ‘html’,data.data, that, 5)
}
});//读取本地文件内
},
fail: console.error
})