When writing out a file using <write>, what is the default encoding of the file? Is there anyway to save the file in a different encoding?
No encoding is used; whatever is printed is copied verbatim to the file. There are various <fmt> codes to encode output, e.g. to print ISO-8859-1 data in $string as UTF-8 to the file:
<write $theFile>
<fmt "%V" $string>
</write>
Note that if htmlmode is on (the default for .html function extensions), HTML-escapement of literal-printed variables (`$var' instead of e.g. `<fmt "%s" $var>') will occur in the file, just as it would if the variables were printed to stdout.