Implement write replacement to handle OEM codepages
clear: undo mingw32-specific changes