int SetOriginText(byte[] baOrigin, Encoding encoding, out string strError) { strError = ""; if (encoding == null) { int nRet = this.MainForm.GetEncoding(this.comboBox_originDataEncoding.Text, out encoding, out strError); if (nRet == -1) { return(-1); } } else { this.comboBox_originDataEncoding.Text = GetEncodingForm.GetEncodingName(this.CurrentEncoding); } this.textBox_originData.Text = encoding.GetString(baOrigin); return(0); }
// 获得encoding的正式名字。本函数可以识别Marc8Encoding类 public static string GetEncodingName(Encoding encoding) { EncodingInfo info = GetEncodingForm.GetEncodingInfo(encoding); if (info != null) { return(info.Name); } else { if (encoding is Marc8Encoding) { return("MARC-8"); } else { return("Unknown encoding"); } } }
void menuItem_setDefualtEncoding_Click(object sender, EventArgs e) { ZConnection connection = this.GetCurrentZConnection(); GetEncodingForm dlg = new GetEncodingForm(); GuiUtil.SetControlFont(dlg, this.Font); dlg.Encoding = connection.ForcedRecordsEncoding; dlg.StartPosition = FormStartPosition.CenterScreen; dlg.ShowDialog(this); if (dlg.DialogResult != DialogResult.OK) return; connection.ForcedRecordsEncoding = dlg.Encoding; // 刷新listview内的全部行 RefreshBrowseViewDisplay(); }