Write UTF-8 encoded data

From CodeCodex

Implementations[edit]

Java[edit]

    try {
        Writer out = new BufferedWriter(new OutputStreamWriter(
            new FileOutputStream("outfilename"), "UTF8"));
        out.write(aString);
        out.close();
    } catch (UnsupportedEncodingException e) {
    } catch (IOException e) {
    }

Seed7[edit]

The "utf8.s7i" library contains support for UTF-8 files:

include "utf8.s7i";

const proc: write_utf8_file is func
  local
    var file: outFile is STD_NULL;
  begin
    outFile := open_utf8("outfilename", "w");
    if outFile <> STD_NULL then
      write(outFile, aString);
      close(outFile);
    end if;
  end func;