问题描述
举个例子,当我使用FileReader API从文件中读取π字符( \ u03C0
)时,我将pi字符带回给我使用预期的 FileReader.readAsText(blob)
读取它。但是当我使用 FileReader.readAsBinaryString(blob)
时,我得到结果 \ xcf \ x80
,而不是似乎与pi字符没有任何明显的相关性。这是怎么回事? (这可能与编码UTF-8/16的方式有关...)
So as an example, when I read the π character (\u03C0
) from a File using the FileReader API, I get the pi character back to me when I read it using FileReader.readAsText(blob)
which is expected. But when I use FileReader.readAsBinaryString(blob)
, I get the result \xcf\x80
instead, which doesn't seem to have any visible correlation with the pi character. What's going on? (This probably has something to do with the way UTF-8/16 is encoded...)
推荐答案
哦,好吧,如果这就是你所需要的...... :)
Oh well, if that's all you needed... :)
CF80
是π的UTF-8编码。
CF80
is the UTF-8 encoding for π.
这篇关于使用FileReader在readAsBinaryString和readAsText之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!