readAsText()
方法在
FileReaderSync
interface allows to read
File
or
Blob
objects in a synchronous way into an
DOMString
. This interface is
only available
in
workers
as it enables synchronous I/O that could potentially block.
readAsText(File); readAsText(Blob); readAsText(File, encoding); readAsText(Blob, encoding);
blob
File
or
Blob
to read.
encoding
The optional parameter specifies encoding to be used (e.g., iso-8859-1 or UTF-8). If not present, the method will apply a detection algorithm for it.
DOMString
representing the input data.
The following exceptions can be raised by this method:
NotFoundError
File
or
Blob
cannot be found, e.g. because it has been erased.
SecurityError
NotReadableError
is raised when the resource cannot be read due to a permission problem, like a concurrent lock.
EncodingError
is raised when the resource is a data URL and exceed the limit length defined by each browser.
| 规范 | 状态 | 注释 |
|---|---|---|
|
文件 API
The definition of 'readAsText' in that specification. |
工作草案 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
readAsText
|
Chrome Yes | Edge 12 | Firefox 8 | IE Yes | Opera Yes | Safari Yes | WebView Android Yes | Chrome Android Yes | Firefox Android 8 | Opera Android Yes | Safari iOS Yes | Samsung Internet Android Yes |
完整支持
FileReaderSync