Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support BOM head on win , linux #3369

Open
kasini3000 opened this issue Jul 3, 2024 · 2 comments · May be fixed by #3396
Open

support BOM head on win , linux #3369

kasini3000 opened this issue Jul 3, 2024 · 2 comments · May be fixed by #3396

Comments

@kasini3000
Copy link

kasini3000 commented Jul 3, 2024

support BOM head on win , linux

Because both 'vi' and 'vim' under Linux supports bom headers.

Specifications

  1. Detect the three bytes in the file header.
  2. According to the encoding meaning of bytes, parse and open the text file.
  3. Save the text file according to the original encoding of the file and the BOM header.

Golang should have such a library.

Commit hash:
OS:
Terminal:

@niten94
Copy link
Contributor

niten94 commented Jul 6, 2024

The encoding can be set when doing something like running micro -encoding utf-16 file.txt or entering setlocal encoding utf-16 and reopen in micro, but BOM is read as a character that can be edited so I think it has to be detected.

I have not used Go much before and I do not know if there are other encodings with BOM that are used a lot, but I was only able to find 1 package where BOM and encoding can be detected:
https://pkg.go.dev/github.com/dimchansky/utfbom

I think I can try adding support with detecting BOM using the package and making a pull request if detecting encodings in the list of Encoding values in the page only would be fine.

@kasini3000
Copy link
Author

image

@niten94 niten94 linked a pull request Jul 19, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants