fix #3832: use the locale encoding in openTempFile