Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
api:buffer [2016/06/19 07:53]
payonel [Interface Methods]
api:buffer [2016/06/19 07:56] (current)
payonel [Instance Methods]
Line 65: Line 65:
     * a number value, e.g. `10`     * a number value, e.g. `10`
  
-    Read **n** bytes (in binary mode) or chars (in text mode) from the stream; result is returned as a string. See [[api:​non-standard-lua#​input_and_output_facilities|io.open]] for more details about how to open files in different modes.+    Read **n** bytes (in binary mode) or chars (in text mode) from the stream; result is returned as a string. See [[api:​non-standard-lua-libs#​input_and_output_facilities|io.open]] for more details about how to open files in different modes.
  
     `local chars = b:read(10)`     `local chars = b:read(10)`
Line 71: Line 71:
     * "​\*n"​ or "​\*number"​     * "​\*n"​ or "​\*number"​
  
-    Read the next series of bytes from the stream that can be interpreted as a number. Note that reading numbers is also affected by the open mode, binary or text. See [[api:​non-standard-lua#​input_and_output_facilities|io.open]] for more details about how to open files in different modes..+    Read the next series of bytes from the stream that can be interpreted as a number. Note that reading numbers is also affected by the open mode, binary or text. See [[api:​non-standard-lua-libs#​input_and_output_facilities|io.open]] for more details about how to open files in different modes..
  
     `local number = b:​read("​*n"​)`     `local number = b:​read("​*n"​)`
Line 134: Line 134:
 - `read(n: number) ok, reason` - `read(n: number) ok, reason`
  
-  Return `n` bytes, and **not** `n` unicode-aware chars. Assume your data is binary data and let the buffer library manage the mode and the unicode string packaging (if applicable). Note that this is exactly how the filesystem library operates.The caller assumes there is more data to read until `nil` is returned. A empty string or a string shorter than `n` chars long is a valid return, but the caller may assume there is more data to request until `nil` is returned.+  Return `n` bytes, and **not** `n` unicode-aware chars. Assume your data is binary data and let the buffer library manage the mode and the unicode string packaging (if applicable). Note that this is exactly how the [[api:filesystem|filesystem]] ​library operates.The caller assumes there is more data to read until `nil` is returned. A empty string or a string shorter than `n` chars long is a valid return, but the caller may assume there is more data to request until `nil` is returned.
  
 - `seek([whence:​ string], [offset: number]) [offset from start] or falsey, reason` - `seek([whence:​ string], [offset: number]) [offset from start] or falsey, reason`