Skip to content

Modern Fs TextReader Encoding

Paul Squires edited this page Oct 24, 2026 · 4 revisions

Home › Filesystem › File Streams › TextReader.Encoding

TextReader.Encoding

Returns the encoding found at the start: utf-8, utf-16le or utf-16be.

Syntax

TextReader.Encoding( )

Notes

  • "utf-8", "utf-16le" or "utf-16be" once the first read has looked at the start of the data; "" before that.
  • A reader given an encoding, or one that detected a code page, names it the same way: "windows-1252", "ansi", "binary", and so on. Detected( ) returns the encoding itself, with Bom true when the data started with one.

Examples

#import "std/fs"
using fs

dim as MemoryStream m = MemoryStream( "x" )
dim as TextReader tr = TextReader( m )
dim as ustring ln
tr.ReadLine( ln )
print tr.Encoding( )    '' utf-8

Library: Filesystem Library Category: File Streams Documented under: Streams

Clone this wiki locally