简体   繁体   中英

convert text hex to real hex representation C++

I have the following file format | 00 00 07 09 | for example in a text file I need for a way to parse it so that each time I find a string between "|" convert the inside to real hex representation

for instance | 30 | will give me 0 how can it be done in C++ (damn C# makes you so lazy and dump).

this is the common format of the file

+++ath

|FF F4 FF FD 06|

/viewsource/template.html?

NAMENAME

|FF FF FF FF FF FF|

|13|

|05|

|00 00 00 08|

|00|

|0A|

|00 00|

c|82|Sc

=

GET

FTP|3A|/

|01 06 00 00 00|

HTTP/

PROPFIND

each line will be saved in a vector array that will be passed to the following function.

void WuManber::Initialize( const vector<const char *> &patterns, 
                  bool bCaseSensitive, bool bIncludeSpecialCharacters, bool       bIncludeExtendedAscii )

use stringstream

#include <sstream>
using namespace std;

void foo()
{
    istringstream ss("30");
    int i;
    ss >> hex >> i;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM