MCPcopy Create free account
hub / github.com/cxasm/notepad-- / convertFileCode

Method convertFileCode

src/encodeconvert.cpp:429–454  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

427};
428
429QFuture<EncodeThreadParameter_*> EncodeConvert::convertFileCode(QString filePath, QTreeWidgetItem* item)
430{
431 EncodeThreadParameter_* p = new EncodeThreadParameter_(filePath);
432 p->item = item;
433
434 CODE_ID srcCode = static_cast<CODE_ID>(item->data(0, ITEM_CODE).toInt());
435
436 CODE_ID dstCode = getComboBoxCode(ui.codeToComboBox->currentIndex());
437
438
439 //int 0相等 1 不等
440 return commitTask([=](EncodeThreadParameter_* parameter)->EncodeThreadParameter_*
441 {
442 if (dstCode != CODE_ID::UNKOWN)
443 {
444 parameter->code = convertFileToCode(parameter->filepath, srcCode, dstCode);
445 }
446 else
447 {
448 parameter->code = UNKOWN;
449 }
450 return parameter;
451 }
452 , p);
453
454}
455
456//20220114 仅仅使用第一行失败编码还是不行,因为utf8和gbk其实有相同的编码范围。
457//如果识别第一行为gbk的,则直接使用gbk。但是如果识别为utf8的,则需要识别更多的文本内容,这样会更慢

Callers 1

slot_startConvertMethod · 0.95

Calls 1

dataMethod · 0.80

Tested by

no test coverage detected