MCPcopy Create free account
hub / github.com/ON4QZ/QSSTV / hexFromString

Function hexFromString

src/utils/hexconvertor.cpp:3–27  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1#include "hexconvertor.h"
2
3bool hexFromString(QString s,QByteArray &ba,bool toHex)
4{
5 int i,j;
6 unsigned char res;
7 bool ok;
8 QString tmp;
9 if(toHex)
10 {
11 if((s.length()&1)!=0) return false;
12 ba.resize(s.length()/2);
13 for(i=0,j=0;i<s.length();i+=2,j++)
14 {
15 tmp="0x";
16 tmp+=s.mid(i,2);
17 res=tmp.toInt(&ok,16);
18 if(!ok) return false;
19 ba[j]=res;
20 }
21 }
22 else
23 {
24 ba=s.toLatin1();
25 }
26 return true;
27}
28

Callers 1

slotSetFrequencyMethod · 0.85

Calls 1

resizeMethod · 0.80

Tested by

no test coverage detected