Closed ebcpass closed 6 years ago
Hi @ebcpass ,
Yes it's possible to add support for cp936
, however I am not in a position to implement this.
If you'd like, can you please submit a PR?
Thanks
Closed due to inactivity. Will reopen if activity occurs
I doing it now, but i have a bug. I import System.Text.Encoding.CodePages package, an add {"cp936", Encoding.GetEncoding(936) } to CharsetMap
when i used cp936 charset this function ` public void Handle(IToken token) { switch (token) { case EnvironmentChangeToken t: foreach (var change in t.Changes) { Logger.Instance?.WriteLine($"{t.Type}: {change.Type} - {change.OldValue} -> {change.NewValue}"); switch (change.Type) { case EnvironmentChangeToken.ChangeType.TDS_ENV_DB: _environment.Database = change.NewValue; break; case EnvironmentChangeToken.ChangeType.TDS_ENV_PACKSIZE: if (int.TryParse(change.NewValue, out int newPackSize)) { _environment.PacketSize = newPackSize; } break; case EnvironmentChangeToken.ChangeType.TDS_ENV_CHARSET: Console.WriteLine(change.OldValue); Console.WriteLine(change.NewValue); if (string.IsNullOrEmpty(change.NewValue.Trim())) { break; }
if (CharsetMap.ContainsKey(change.NewValue))
{
_environment.Encoding = CharsetMap[change.NewValue];
}
else
{
throw new AseException($"Server environment changed to unsupported charset {change.NewValue}");
}
break;
}
}
break;
case OptionCommandToken o:
if (o.Option == OptionCommandToken.OptionType.TDS_OPT_TEXTSIZE)
{
_environment.TextSize = BitConverter.ToInt32(o.Arguments, 0);
Logger.Instance?.WriteLine($"{o.Type}: {o.Option} -> {_environment.TextSize}");
}
break;
default:
return;
}`
case EnvironmentChangeToken.ChangeType.TDS_ENV_CHARSET change.NewValue is Empty on linux server
on windwos server is OK.
if fix it by this code
if (string.IsNullOrEmpty(change.NewValue.Trim())) { change.NewValue = change.OldValue; }
but i don't trust myself !!!
Can you support cp936 charset?