seanliang / ConvertToUTF8

A Sublime Text 2 & 3 plugin for editing and saving files encoded in GBK, BIG5, EUC-KR, EUC-JP, Shift_JIS, etc.
https://github.com/seanliang/ConvertToUTF8
MIT License
900 stars 178 forks source link

Use extended attributes on macOS to save/load text encoding #83

Open gingerbeardman opened 6 years ago

gingerbeardman commented 6 years ago

Proposal

Use xattr (extended attributes) on macOS to save/load text encoding with file.

BBEdit is the only editor I've found that already does this.

Also you should honour any existing com.apple.TextEncoding when loading and keep it when saving.

Background

Benefits

Details

debug command: xattr -p -l com.apple.TextEncoding "/path/to/file.txt"

output: file.txt com.apple.TextEncoding: Shift_JIS;2561

to set xattr (from terminal): xattr -w com.apple.TextEncoding "Shift_JIS;2561" "/path/to/file.txt"

References

these may help with implementation:

gingerbeardman commented 4 years ago

Any thoughts on this?