[fpc-devel] Trying to understand the wiki-Page "FPC Unicodesupport"

Hans-Peter Diettrich DrDiettrich1 at aol.com
Thu Nov 27 16:24:54 CET 2014


Jonas Maebe schrieb:
> On 26/11/14 21:25, Hans-Peter Diettrich wrote:

>> What about file I/O?
>> It should be possible to read (and write) files of either endianness.
> 
> Standard I/O only supports single byte code pages (which should be
> documented).

Please clarify "single byte code pages".

SBCS are a subset of the ANSI/ISO codepages, with the complement being MBCS.

Did you mean that basic I/O is implemented for AnsiString (byte based) 
only, not for UnicodeString (word based)?

> Reading a unicodestring from a text file converts from the
> single byte code page to the native-endianess UTF-16 format.

Is this different from assigning an AnsiString to an UnicodeString?

While it certainly is a stupid (Microsoft) idea to use UTF-16 for file 
storage, we'll have to take that into account.

Just with file I/O it makes sense to allow for *all* encodings (see 
BOM), including UTF-16. The file encoding must be independent from the 
string type and encoding, used to hold the file data in memory. See 
Delphi TEncoding, for use with streams (TStreamReader/Writer) and TStrings.

DoDi




More information about the fpc-devel mailing list