将文本十六进制转换为实数十六进制表示形式 [英] convert text hex to real hex representation C++
问题描述
我有以下文件格式| 00 00 07 09 |例如在一个文本文件中
我需要一种解析方法,这样每次我在|之间找到一个字符串时,将内部转换为真正的十六进制表示
例如| 30 |会给我0如何在C ++中完成(该死的C#让你如此懒惰和转储)。
这是该文件的常见格式
+++ ath
| FF F4 FF FD 06 |
/viewsource/template.html?
NAMENAME
| 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
每行将被保存在一个向量数组
中,并将被传递给下面的函数。
void WuManber: :初始化(const vector< const char *>& patterns,
bool bCaseSensitive,bool bIncludeSpecialCharacters,bool bIncludeExtendedAscii)
#include< sstream>
使用namespace std;
void foo()
{
istringstream ss(30);
int i;
ss>> hex>>一世;
}
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;
}
这篇关于将文本十六进制转换为实数十六进制表示形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!