将文本十六进制转换为实数十六进制表示形式

编程入门 行业动态 更新时间:2024-10-21 19:54:35
本文介绍了将文本十六进制转换为实数十六进制表示形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有以下文件格式| 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; }

更多推荐

将文本十六进制转换为实数十六进制表示形式

本文发布于:2023-10-23 05:51:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1519981.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:实数   转换为   文本   形式   十六进制

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!