@@ -25,6 +25,7 @@ import (
2525 "github.com/zyedidia/micro/v2/internal/screen"
2626 "github.com/zyedidia/micro/v2/internal/util"
2727 "github.com/zyedidia/micro/v2/pkg/highlight"
28+ "golang.org/x/text/encoding"
2829 "golang.org/x/text/encoding/htmlindex"
2930 "golang.org/x/text/encoding/unicode"
3031 "golang.org/x/text/transform"
@@ -87,6 +88,8 @@ type SharedBuffer struct {
8788 // LocalSettings customized by the user for this buffer only
8889 LocalSettings map [string ]bool
8990
91+ encoding encoding.Encoding
92+
9093 Suggestions []string
9194 Completions []string
9295 CurSuggestion int
@@ -337,9 +340,9 @@ func NewBuffer(r io.Reader, size int64, path string, startcursor Loc, btype BufT
337340 }
338341 config .UpdatePathGlobLocals (b .Settings , absPath )
339342
340- enc , err : = htmlindex .Get (b .Settings ["encoding" ].(string ))
343+ b . encoding , err = htmlindex .Get (b .Settings ["encoding" ].(string ))
341344 if err != nil {
342- enc = unicode .UTF8
345+ b . encoding = unicode .UTF8
343346 b .Settings ["encoding" ] = "utf-8"
344347 }
345348
@@ -350,7 +353,7 @@ func NewBuffer(r io.Reader, size int64, path string, startcursor Loc, btype BufT
350353 return NewBufferFromString ("" , "" , btype )
351354 }
352355 if ! hasBackup {
353- reader := bufio .NewReader (transform .NewReader (r , enc .NewDecoder ()))
356+ reader := bufio .NewReader (transform .NewReader (r , b . encoding .NewDecoder ()))
354357
355358 var ff FileFormat = FFAuto
356359
0 commit comments