减少不必要的报错
This commit is contained in:
parent
305201f23e
commit
55dcfed653
@ -45,25 +45,25 @@ namespace DocumentManagement
|
|||||||
|
|
||||||
private void Eet_ContentChanging(object eventSender, ContentChangingEventArgs args)
|
private void Eet_ContentChanging(object eventSender, ContentChangingEventArgs args)
|
||||||
{
|
{
|
||||||
if (eventSender is XTextInputFieldElement xife)
|
if (eventSender is XTextInputFieldElement xife&& args.InsertingElements is { })
|
||||||
{
|
{
|
||||||
var txtAll = args.InsertingElements.Select(c => c.Text).ToList();
|
var txtAll = args.InsertingElements.Select(c => c.Text).ToList();
|
||||||
var txt = string.Concat(txtAll);
|
var txt = string.Concat(txtAll);
|
||||||
if (txtAll.Any(c=>c.Contains("<22>")))
|
if (txtAll.Any(c=>c.Contains("<22>")))
|
||||||
{
|
{
|
||||||
|
|
||||||
var clip = Clipboard.GetText().Trim();
|
var clip = Clipboard.GetText()?.Trim();
|
||||||
xife.Text = clip;
|
xife.Text = clip;
|
||||||
args.Cancel = true;
|
args.Cancel = true;
|
||||||
return;
|
return;
|
||||||
args.InsertingElements.Clear();
|
args.InsertingElements.Clear();
|
||||||
args.InsertingElements.Add(new XTextStringElement() { Text = clip });
|
args.InsertingElements.Add(new XTextStringElement() { Text = clip });
|
||||||
}
|
}
|
||||||
byte[] originalBytes = Encoding.UTF8.GetBytes(txt); // 这里使用 UTF8 是假设或猜测
|
//byte[] originalBytes = Encoding.UTF8.GetBytes(txt); // 这里使用 UTF8 是假设或猜测
|
||||||
string decodedString = Encoding.GetEncoding("GB2312").GetString(originalBytes); // 用其他编码尝试解码
|
//string decodedString = Encoding.GetEncoding("GB2312").GetString(originalBytes); // 用其他编码尝试解码
|
||||||
|
|
||||||
byte[] originalBytes2 = Encoding.GetEncoding("GB2312").GetBytes(txt); // 这里使用 UTF8 是假设或猜测
|
//byte[] originalBytes2 = Encoding.GetEncoding("GB2312").GetBytes(txt); // 这里使用 UTF8 是假设或猜测
|
||||||
string decodedString2 = Encoding.UTF8.GetString(originalBytes2); // 用其他编码尝试解码
|
//string decodedString2 = Encoding.UTF8.GetString(originalBytes2); // 用其他编码尝试解码
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user