WriteStringFormat()

Syntax

Result = WriteStringFormat(#File, Format)
Description
Writes a BOM (Byte Order Mark) at the current position in the file.

Parameters

#File The file to write to.
Format The format for which the mark should be written. It can be one of the following values:
  #PB_Ascii  : Writes no BOM at all (this is usually interpreted as an plain Ascii file.)
  #PB_UTF8   : UTF-8 BOM
  #PB_Unicode: UTF-16 (little endian) BOM

  #PB_UTF16BE: UTF-16 (big endian) BOM
  #PB_UTF32  : UTF-32 (little endian) BOM
  #PB_UTF32BE: UTF-32 (big endian) BOM
The #PB_Ascii, #PB_UTF8 and #PB_Unicode correspond to the flags supported by WriteString() and WriteStringN(). After placing such a BOM, the strings which follow should all be written with this flag. The other formats represent string formats that can not be written directly with the PureBasic string functions. They are included only for completeness.

Return value

Returns nonzero if the operation was successful and zero if it failed.

Remarks

The file must be opened using a write-capable function (i.e. not with ReadFile()).

The Byte Order Mark is a commonly used method with which to indicate the encoding of a textfile. It is usually placed at the beginning of the file. It is however not a standard, just a commonly used practice. So if no BOM is detected at the start of a file, it does not necessarily mean that it is a plain text file. It could also just mean that the program that created the file did not use this practice. ReadStringFormat() may be used detect a BOM within a file.

For more information, see this Wikipedia Article.

See Also

ReadStringFormat(), WriteString(), WriteStringN(), CreateFile()

Supported OS

All

<- WriteString() - File Index - WriteStringN() ->