icsharpcode / SharpDevelop

#develop (short for SharpDevelop) is a free IDE for .NET programming languages.
2.07k stars 771 forks source link

F# Interactive Encoding #779

Open FallenPhoenix opened 7 years ago

FallenPhoenix commented 7 years ago

Hello again. I found one more encoding issue, and now its FSI.exe process. It should be current system language OEM encoding, because there language pack available: https://www.microsoft.com/en-us/download/details.aspx?id=48179

FSharpInteractive.cs, lines starting from 76:

            if (foundCompiler) {
                var encoding = Encoding.ASCII;
                var lang = System.Globalization.CultureInfo.CurrentUICulture;
                var bin_path = Path.GetDirectoryName(fsiProcess.StartInfo.FileName);
                if (File.Exists(string.Format(@"{0}\{1}\Fsi.resources.dll", bin_path, lang.Name)));
                    encoding = Encoding.GetEncoding(lang.TextInfo.OEMCodePage);
                //fsiProcess.StartInfo.Arguments <- "--fsi-server sharpdevelopfsi";
                fsiProcess.StartInfo.UseShellExecute = false;
                fsiProcess.StartInfo.CreateNoWindow = true;
                fsiProcess.StartInfo.RedirectStandardError = true;
                fsiProcess.StartInfo.RedirectStandardInput = true;
                fsiProcess.StartInfo.RedirectStandardOutput = true;
                fsiProcess.StartInfo.StandardErrorEncoding = encoding;
                fsiProcess.StartInfo.StandardOutputEncoding = encoding;
                fsiProcess.EnableRaisingEvents = true;

Maybe it's not absolutely correct fix, but for me it works (Russian locale), and probably for other supported languages too.

Full path for Russian resource dll for me is: C:\Program Files (x86)\Microsoft F#\v4.0\ru\Fsi.resources.dll

FallenPhoenix commented 7 years ago

Maybe also possible to use this OemEncoding instead (screenshot from 3rd version): image