figment/tesvsnip — Issue #4: Load and view correct locale string (Russian, English, etc.)
Author: MrRaven
Created: 2012-01-05 12:16:36+00:00
State: open

*.esp, *.esm locale string code page always - 1252
but *.DLSTRINGS, *.ILSTRINGS, *.STRINGS locale string store in locale code page (English - 1252, Russian - 1251, etc.)

public sealed class Plugin
==========================

* internal Plugin(string FilePath, bool headerOnly, string[] recFilter)
* internal void Save(string FilePath)
....
string prefix = Path.Combine(Path.Combine(Path.GetDirectoryName(FilePath), "Strings"), Path.GetFileNameWithoutExtension(FilePath));
FileInfo[] f = (new DirectoryInfo(Path.Combine(Path.GetDirectoryName(FilePath), "Strings"))).GetFiles("Skyrim_*.STRINGS");
string localeprefix = String.Empty;
//returns a locale language prefix (for russian - "_Russian", for english - "_English", etc.)
if (f.Length != 0) localeprefix = (Path.GetFileNameWithoutExtension(f[0].Name)).Substring(6);
if (!String.IsNullOrEmpty(localeprefix)) prefix += localeprefix;
else prefix += "_" + global::TESVSnip.Properties.Settings.Default.LocalizationName;
....

* private LocalizedStringDict LoadPluginStrings(LocalizedStringFormat format, BinaryReader reader)
....
//Gets an encoding for the operating system's current user ANSI code page (Russian - 1251, English - 1252, etc.)
string str = Encoding.Default.GetString(data, start, len);
//string str = System.Text.ASCIIEncoding.ASCII.GetString(data, start, len);
....

* private void SavePluginStrings(LocalizedStringFormat format, LocalizedStringDict strings, BinaryWriter writer)
....
//Set an encoding for the operating system's current user ANSI code page (Russian - 1251, English - 1252, etc.)
byte[] data = Encoding.Default.GetBytes(kvp.Value);
//byte[] data = System.Text.ASCIIEncoding.ASCII.GetBytes(kvp.Value);
....
public sealed class SubRecord
=============================
* public override void GetFormattedData(RTF.RTFBuilder s, SelectionContext context)
....
case ElementValueType.LString:
....
if (!sselem.notininfo)
{
int start = offset;
while (Data[offset] != 0) offset++;
s.Append(Encoding.Default.GetString(Data, start, offset));
//while (Data[offset] != 0) s.Append((char)Data[offset++]);
}
....