Skip to content

Commit

Permalink
FN Use UTF8 temp files
Browse files Browse the repository at this point in the history
  • Loading branch information
nightroman committed Nov 15, 2023
1 parent e6563c5 commit e3ffb96
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
13 changes: 6 additions & 7 deletions FarNet/FarNet/Works/Editor/EditorTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;

namespace FarNet.Works;
Expand Down Expand Up @@ -33,8 +32,7 @@ static IEditor EditTextCreate(EditTextArgs args)

//! avoid native API, do not use TempName
editor.FileName = Kit.TempFileName(args.Extension);

editor.CodePage = 1200;
editor.CodePage = 65001;
editor.DisableHistory = true;
if (!string.IsNullOrEmpty(args.Title))
editor.Title = args.Title;
Expand All @@ -45,7 +43,7 @@ static IEditor EditTextCreate(EditTextArgs args)

//? unlikely throws
if (!string.IsNullOrEmpty(args.Text))
File.WriteAllText(editor.FileName, args.Text, Encoding.Unicode);
File.WriteAllText(editor.FileName, args.Text);

return editor;
}
Expand All @@ -61,7 +59,7 @@ static IEditor EditTextCreate(EditTextArgs args)
if (File.Exists(editor.FileName))
{
// read and return
return File.ReadAllText(editor.FileName, Encoding.Unicode);
return File.ReadAllText(editor.FileName);
}
else
{
Expand Down Expand Up @@ -110,12 +108,13 @@ static IEditor EditTextCreate(EditTextArgs args)
public static void ViewText(string text, string title, OpenMode mode)
{
string tmpfile = Far.Api.TempName();
File.WriteAllText(tmpfile, text, Encoding.Unicode);
File.WriteAllText(tmpfile, text);

var viewer = Far.Api.CreateViewer();
viewer.FileName = tmpfile;
viewer.CodePage = 65001;
viewer.DeleteSource = DeleteSource.File; // yes, File - we can control it
viewer.DisableHistory = true;
viewer.FileName = tmpfile;
viewer.Switching = Switching.Enabled;
viewer.Title = title;
viewer.Open(mode);
Expand Down
3 changes: 3 additions & 0 deletions FarNet/FarNetMan/FarNetMan.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -295,5 +295,8 @@
<PostBuildEvent>
<Command>ib Install $(SolutionDir)\FarNet\FarNet.build.ps1 -Platform $(Platform) -Configuration $(Configuration)</Command>
</PostBuildEvent>
<ClCompile>
<AdditionalOptions>/Wv:18 %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
</ItemDefinitionGroup>
</Project>
4 changes: 4 additions & 0 deletions FarNet/History.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
https://www.nuget.org/packages/FarNet
Far Manager 3.0.5505

= 7.0.14 =

Use UTF8 temp files for EditText() and ViewText().

= 7.0.13 =

- Add Tasks.ExecuteAndCatch().
Expand Down
2 changes: 1 addition & 1 deletion Get-Version.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
$FarVersion = "3.0.5505"
$FarNetVersion = "7.0.13"
$FarNetVersion = "7.0.14"
$PowerShellFarVersion = "7.0.22"

0 comments on commit e3ffb96

Please sign in to comment.