diff --git a/Far2bis/editor.cpp b/Far2bis/editor.cpp
index e6a8803..af7732b 100644
--- a/Far2bis/editor.cpp
+++ b/Far2bis/editor.cpp
@@ -4715,21 +4715,35 @@ BOOL Editor::IsFileModified() const
 }
 
 // используется в FileEditor
-long Editor::GetCurPos()
+long Editor::GetCurPos(bool file_pos, bool add_bom)
 {
 	Edit *CurPtr=TopList;
 	long TotalSize=0;
+	int mult = 1, bom = 0;
+	if ( file_pos ) {
+		if ( m_codepage == CP_UNICODE || m_codepage == CP_REVERSEBOM ) {
+			mult = 2;
+			if ( add_bom ) bom += 2;
+		}
+		else if ( m_codepage == CP_UTF8 ) {
+			mult = -1;
+			if ( add_bom ) bom += 3;
+		}
+	}
 
 	while (CurPtr!=TopScreen)
 	{
 		const wchar_t *SaveStr,*EndSeq;
 		int Length;
 		CurPtr->GetBinaryString(&SaveStr,&EndSeq,Length);
-		TotalSize+=Length+StrLength(EndSeq);
+		if ( mult > 0 )
+			TotalSize += Length + StrLength(EndSeq);
+		else
+			TotalSize -= WideCharToMultiByte(CP_UTF8,0,SaveStr,Length,nullptr,0,nullptr,nullptr)+StrLength(EndSeq);
 		CurPtr=CurPtr->m_next;
 	}
 
-	return(TotalSize);
+	return TotalSize * mult + bom;
 }
 
 
@@ -6797,7 +6811,7 @@ Edit *Editor::InsertString(const wchar_t *lpwszStr, int nLength, Edit *pAfter, i
 }
 
 
-void Editor::SetCacheParams(EditorCacheParams *pp)
+void Editor::SetCacheParams(EditorCacheParams *pp, bool count_bom)
 {
 	bool translateTabs=false;
 	SavePos=pp->SavePos;
@@ -6807,13 +6821,28 @@ void Editor::SetCacheParams(EditorCacheParams *pp)
 	{
 		Edit *CurPtr=TopList;
 		long TotalSize=0;
+		bool utf8 = false;
+ 
+		if ( m_codepage == CP_UNICODE || m_codepage == CP_REVERSEBOM ) {
+			StartChar /= 2;
+			if ( count_bom )
+				--StartChar;
+		}
+		else if ( m_codepage == CP_UTF8 ) {
+			utf8 = true;
+			if ( count_bom )
+				StartChar -= 3;
+		}
 
 		while (CurPtr && CurPtr->m_next)
 		{
 			const wchar_t *SaveStr,*EndSeq;
 			int Length;
 			CurPtr->GetBinaryString(&SaveStr,&EndSeq,Length);
-			TotalSize+=Length+StrLength(EndSeq);
+			if ( utf8 )
+				Length = WideCharToMultiByte(CP_UTF8,0, SaveStr,Length, nullptr, 0, nullptr,nullptr);
+ 
+			TotalSize += Length + StrLength(EndSeq);
 
 			if (TotalSize > StartChar)
 				break;
diff --git a/Far2bis/editor.hpp b/Far2bis/editor.hpp
index 7c04096..10aa3a6 100644
--- a/Far2bis/editor.hpp
+++ b/Far2bis/editor.hpp
@@ -303,7 +303,7 @@ class Editor:public ScreenObject
 
 	public:
 
-		void SetCacheParams(EditorCacheParams *pp);
+		void SetCacheParams(EditorCacheParams *pp, bool count_bom=false);
 		void GetCacheParams(EditorCacheParams *pp);
 
 		bool SetCodePage(UINT codepage);  //BUGBUG
@@ -321,7 +321,7 @@ class Editor:public ScreenObject
 		BOOL IsFileModified() const;
 		BOOL IsFileChanged() const;
 		void SetTitle(const wchar_t *Title);
-		long GetCurPos();
+		long GetCurPos(bool file_pos=false, bool add_bom=false);
 		int EditorControl(int Command,void *Param);
 		void SetHostFileEditor(FileEditor *Editor) {HostFileEditor=Editor;};
 		static void SetReplaceMode(int Mode);
diff --git a/Far2bis/farversion.m4 b/Far2bis/farversion.m4
index fb940c4..26c5657 100644
--- a/Far2bis/farversion.m4
+++ b/Far2bis/farversion.m4
@@ -10,7 +10,7 @@ m4_define(BLD_MONTH,m4_substr(DATE,3,2))m4_dnl
 m4_define(BLD_DAY,m4_substr(DATE,0,2))m4_dnl
 m4_define(COPYRIGHTYEARS,m4_ifelse(`2000',BLD_YEAR,`2000',`2000-'BLD_YEAR))m4_dnl
 m4_define(MAKEFULLVERSION,`m4_ifelse(
-`',$1,`MAJOR.MINOR (build BUILD bis21.6) $2',
+`',$1,`MAJOR.MINOR (build BUILD bis21.8) $2',
 `RC',$1,`MAJOR.MINOR RC (build BUILD) $2',
 `alpha',$1,`MAJOR.MINOR alpha (build BUILD) $2',
 `beta',$1,`MAJOR.MINOR beta (build BUILD) $2',
diff --git a/Far2bis/fileedit.cpp b/Far2bis/fileedit.cpp
index 8a84b07..accc236 100644
--- a/Far2bis/fileedit.cpp
+++ b/Far2bis/fileedit.cpp
@@ -911,7 +911,7 @@ int FileEditor::ReProcessKey(int Key,int CalledFromControl)
 
 				if (!FirstSave || m_editor->IsFileChanged() || apiGetFileAttributes(strFullFileName)!=INVALID_FILE_ATTRIBUTES)
 				{
-					long FilePos=m_editor->GetCurPos();
+					long FilePos=m_editor->GetCurPos(true, m_bAddSignature);
 
 					/* $ 01.02.2001 IS
 					   ! Открываем вьюер с указанием длинного имени файла, а не короткого
@@ -1626,7 +1626,7 @@ int FileEditor::LoadFile(const wchar_t *Name,int &UserBreak)
 
 	EditFile.Close();
 	//if ( bCached )
-	m_editor->SetCacheParams(&cp);
+	m_editor->SetCacheParams(&cp, m_bAddSignature);
 	SysErrorCode=GetLastError();
 	apiGetFindDataEx(Name, FileInfo);
 	EditorGetFileAttributes(Name);
diff --git a/Far2bis/viewer.cpp b/Far2bis/viewer.cpp
index 7bdbc50..c1d60ca 100644
--- a/Far2bis/viewer.cpp
+++ b/Far2bis/viewer.cpp
@@ -1449,6 +1449,7 @@ int Viewer::ProcessKey(int Key)
 		{
 			VM.CodePage = VM.CodePage==GetOEMCP() ? GetACP() : GetOEMCP();
 			lcache_ready = false;
+      AdjustFilePos();
 			ChangeViewKeyBar();
 			Show();
 			CodePageChangedByUser=TRUE;
@@ -1457,8 +1458,6 @@ int Viewer::ProcessKey(int Key)
 		case KEY_SHIFTF8:
 		{
 			UINT nCodePage = SelectCodePage(VM.CodePage, true, true, false, true);
-			lcache_ready = false;
-
 			if (nCodePage != static_cast<UINT>(-1))
 			{
 				if (nCodePage == (CP_AUTODETECT & 0xffff))
@@ -1471,7 +1470,8 @@ int Viewer::ProcessKey(int Key)
 				}
 				CodePageChangedByUser=TRUE;
 				VM.CodePage=nCodePage;
-				SetFileSize();
+				lcache_ready = false;
+				AdjustFilePos();
 				ChangeViewKeyBar();
 				Show();
 			}
@@ -3386,6 +3386,7 @@ void Viewer::SetTitle(const wchar_t *Title)
 void Viewer::SetFilePos(__int64 Pos)
 {
 	FilePos=Pos;
+  AdjustFilePos();
 };
 
 void Viewer::SetPluginData(const wchar_t *PluginData)
-- 
1.7.6.msysgit.0

