Repository navigation
Modern Fs Stream WriteText
Paul Squires edited this page Nov 9, 2026
·
2 revisions
Home › Filesystem › File Streams › Stream.WriteText
Writes a string in a text encoding, the bytes WriteAllText would write.
Stream.WriteText( s, enc [, mode ] ) '' FsResultBool- Writes s encoded in enc, BOM included when enc asks for one, so a stream receives exactly the bytes WriteAllText( p, s, enc ) writes to a file.
- Text written in pieces wants the BOM once: pass the BOM-less form after the first piece, such as Utf16LE( false ), or use a TextWriter, which does that itself.
- Strict by default: a character enc cannot hold fails with FS_INVALID_DATA and nothing is written. With TEXT_REPLACE it becomes ?, the write succeeds, and Value( ) is false.
- An encoding the platform does not support, such as Ansi( ) on Linux and macOS, fails with FS_UNSUPPORTED.
- See Choosing An Encoding.
#import "std/fs"
using fs
dim as MemoryStream m
m.WriteText( "caf" & wchr( &hE9 ), Utf16LE( ) )
print m.Length( ) '' 10: the BOM, then four two-byte charactersLibrary: Filesystem Library Category: File Streams Documented under: Streams
tiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Lambdas
- Block Strings
- Partial Types
- String Slices
- Embed
- Typed Variadics
- C Header Import
- Foreign Library Linking
- UString
- Fixed-Width Types
- Nullptr
- String Library
- Format
- Array
- Map
- Set
- LinkedList
- OrderedMap
- OrderedSet
- Sorting
- Optional
- Result
- Smart Pointers
- Date and Time (Chrono)
- Filesystem
- File Streams
- Config (INI and TOML)
- Codec
- Hash
- UUID
- OS
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- PsControls
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- TIKO_COMPILER
- Variable Declarations
- Standard Data Types
- User Defined Types
- Procedures
- Operators
- Control Flow Statements
- Converting Data Types
- Array Functions
- String Functions
- Mathematical Functions
- Bit Manipulation
- Date and Time Functions
- File I/O Functions
- Console Functions
- User Input (Runtime Library)
- User Input Functions (Graphics Library)
- Screen Functions
- 2D Drawing Functions
- Graphics Library Reference
- Graphics Keyword List
- Memory Functions
- Threading Support Functions
- Error Handling Functions
- Operating System Functions
- Preprocessor
- Intrinsic Defines
- Miscellaneous Keywords
- Modularizing