| 28 | } |
| 29 | |
| 30 | func needsBom() bool { |
| 31 | // The reason why we do this is because notepad.exe on Windows determines the |
| 32 | // encoding of an "empty" text file by the locale, for example, GBK in China, |
| 33 | // while golang string only handles utf8 well. However, a text file with utf8 |
| 34 | // BOM header is not considered "empty" on Windows, and the encoding will then |
| 35 | // be determined utf8 by notepad.exe, instead of GBK or other encodings. |
| 36 | |
| 37 | // This could be enhanced in the future by doing this only when a non-utf8 |
| 38 | // locale is in use, and possibly doing that for any OS, not just windows. |
| 39 | |
| 40 | return runtime.GOOS == "windows" |
| 41 | } |
| 42 | |
| 43 | func edit(editorCommand, fn, initialValue string, stdin io.Reader, stdout io.Writer, stderr io.Writer, cursor showable, lookPath func(string) ([]string, []string, error)) (string, error) { |
| 44 | // prepare the temp file |