TextInputStream allows you to specify an encoding. If you specify UTF-16, then the BOM is part of the encoding and so the TextInputStream should do the right thing. If it doesn't, then you should consider a feedback report.

Charles Yeomans


Hi guys,

I'm wondering how to read a text file in UTF-16 encoding that has an FFFE BOM (little endian).

I don't see any way to specify the endianness with a TextInputStream, so it seems that the solution is to use a BinaryStream like so:

    dim bstr as BinaryStream = File.OpenAsBinaryFile()
    dim b as UInt16 = bstr.ReadUInt16()
    bstr.LittleEndian = (b = &hFFFE)
    dim data as String = bstr.ReadAll(Encodings.UTF16)
    bstr.Close()

However now the compiler tells me that the method ReadAll does not exist in this class, although the documentation says that BinaryStream supports the Readable interface. Is it lying? If so, what is the right way to do this?

Thanks!

Steve

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to