Skip to content

Commit 5effd37

Browse files
committed
Fixed text copy
1 parent 202b403 commit 5effd37

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/core/hexeditor.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,12 @@ vector<uint8_t> &HexEditor::getCurrentData() {
101101
}
102102

103103
string HexEditor::getCurrentDataAsString(unsigned long start, unsigned long len) {
104-
std::string str(this->current_data.begin() + start, this->current_data.begin() + start + len);
104+
string str;
105+
std::for_each(this->current_data.begin() + start, this->current_data.begin() + start + len, [&str](uint8_t const& elem) {
106+
if (elem != 0) {
107+
str.push_back((char)elem);
108+
}
109+
});
105110
return str;
106111
}
107112

src/fhex.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ void Fhex::keyPressEvent(QKeyEvent *event) {
555555
if(event->type() == QKeyEvent::KeyPress) {
556556
if ((event->key() == Qt::Key_Space) && QApplication::keyboardModifiers().testFlag(Qt::ControlModifier)) {
557557
pair<qint64,qint64> offsets = this->qhex->selectedOffsets();
558-
QApplication::clipboard()->setText(QString::fromWCharArray(this->hexEditor->getCurrentDataAsWString(offsets.first, offsets.second - offsets.first).c_str()));
558+
QApplication::clipboard()->setText(this->hexEditor->getCurrentDataAsString(offsets.first, offsets.second - offsets.first).c_str());
559559
this->statusBar.setText("Text copied");
560560
} else if (event->key() == Qt::Key_F5) {
561561
this->loadFile(this->hexEditor->getCurrentPath().c_str());

0 commit comments

Comments
 (0)