| 1 | package checkpoint |
| 2 | |
| 3 | import fileenc "reasonix/internal/fileutil/encoding" |
| 4 | |
| 5 | // encodeRevisionContent re-encodes a v1 text capture for restore, in the |
| 6 | // encoding it was captured in or else the one the file holds now. |
| 7 | func (s *Store) encodeRevisionContent(rev FileRevision, abs string) ([]byte, error) { |
| 8 | enc := fileenc.UTF8 |
| 9 | if rev.Encoding != nil { |
| 10 | enc = *rev.Encoding |
| 11 | } else if current := s.detectCurrentEncoding(abs); current != nil { |
| 12 | enc = *current |
| 13 | } |
| 14 | return fileenc.Encode(*rev.Content, enc) |
| 15 | } |
| 16 |