Skip to content

Instantly share code, notes, and snippets.

@ironpythonbot
Created December 9, 2014 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ironpythonbot/fc5dac2e5179302822f0 to your computer and use it in GitHub Desktop.
Save ironpythonbot/fc5dac2e5179302822f0 to your computer and use it in GitHub Desktop.
CodePlex Issue #34655 Plain Text Attachments
from __future__ import with_statement
from codecs import BOM_UTF8
with open('with_bom.txt', 'w') as f:
f.write(BOM_UTF8 + u'\xe4'.encode('UTF-8'))
with open('without_bom.txt', 'w') as f:
f.write(u'\xe4'.encode('UTF-8'))
with open('with_bom.txt') as f:
print repr(f.read())
with open('without_bom.txt') as f:
print repr(f.read())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment