writeFile method

void writeFile(
  1. String path,
  2. String charset,
  3. bool emitBom
)

Writes the contents to a file. If emitBom is true, then the BOM (also known as a preamble), is emitted for charsets that define a BOM (such as utf-8, utf-16, utf-32, etc.)

Throws a ChilkatException if the call fails; the details are in ChilkatException.lastErrorText. Throws an ArgumentError if a string argument contains a NUL character.

Implementation

void writeFile(String path, String charset, bool emitBom) {
  final h = _handle;
  using((arena) {
    final r = _CkStringBuilder_WriteFile(
      h,
      _toNative(arena, path, 'path'),
      _toNative(arena, charset, 'charset'),
      emitBom ? 1 : 0,
    );
    if (r == 0) {
      throw _fail('writeFile');
    }
  });
}