<tfoot id='Vnxvx'></tfoot>

    <bdo id='Vnxvx'></bdo><ul id='Vnxvx'></ul>

<small id='Vnxvx'></small><noframes id='Vnxvx'>

    1. <i id='Vnxvx'><tr id='Vnxvx'><dt id='Vnxvx'><q id='Vnxvx'><span id='Vnxvx'><b id='Vnxvx'><form id='Vnxvx'><ins id='Vnxvx'></ins><ul id='Vnxvx'></ul><sub id='Vnxvx'></sub></form><legend id='Vnxvx'></legend><bdo id='Vnxvx'><pre id='Vnxvx'><center id='Vnxvx'></center></pre></bdo></b><th id='Vnxvx'></th></span></q></dt></tr></i><div id='Vnxvx'><tfoot id='Vnxvx'></tfoot><dl id='Vnxvx'><fieldset id='Vnxvx'></fieldset></dl></div>
      1. <legend id='Vnxvx'><style id='Vnxvx'><dir id='Vnxvx'><q id='Vnxvx'></q></dir></style></legend>
      2. 如何将一串十六进制值转换为一个字符串?

        How to convert a string of hex values to a string?(如何将一串十六进制值转换为一个字符串?)

          <legend id='iYruZ'><style id='iYruZ'><dir id='iYruZ'><q id='iYruZ'></q></dir></style></legend>

          1. <i id='iYruZ'><tr id='iYruZ'><dt id='iYruZ'><q id='iYruZ'><span id='iYruZ'><b id='iYruZ'><form id='iYruZ'><ins id='iYruZ'></ins><ul id='iYruZ'></ul><sub id='iYruZ'></sub></form><legend id='iYruZ'></legend><bdo id='iYruZ'><pre id='iYruZ'><center id='iYruZ'></center></pre></bdo></b><th id='iYruZ'></th></span></q></dt></tr></i><div id='iYruZ'><tfoot id='iYruZ'></tfoot><dl id='iYruZ'><fieldset id='iYruZ'></fieldset></dl></div>

            <small id='iYruZ'></small><noframes id='iYruZ'>

              <bdo id='iYruZ'></bdo><ul id='iYruZ'></ul>
                <tbody id='iYruZ'></tbody>
              <tfoot id='iYruZ'></tfoot>
                • 本文介绍了如何将一串十六进制值转换为一个字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  假设我有一个字符串:

                  string hex = "48656c6c6f";
                  

                  其中每两个字符对应于其 ASCII 值的十六进制表示,例如:

                  Where every two characters correspond to the hex representation of their ASCII, value, eg:

                  0x48 0x65 0x6c 0x6c 0x6f = "Hello"
                  

                  那么如何从 "48656c6c6f" 获取 "hello" 而不必创建查找 ASCII 表?atoi() 显然在这里不起作用.

                  So how can I get "hello" from "48656c6c6f" without having to create a lookup ASCII table? atoi() obviously won't work here.

                  推荐答案

                  int len = hex.length();
                  std::string newString;
                  for(int i=0; i< len; i+=2)
                  {
                      std::string byte = hex.substr(i,2);
                      char chr = (char) (int)strtol(byte.c_str(), null, 16);
                      newString.push_back(chr);
                  }
                  

                  这篇关于如何将一串十六进制值转换为一个字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  What is the past-the-end iterator in STL C++?(STL C++ 中的最后迭代器是什么?)
                  vector::at vs. vector::operator[](vector::at 与 vector::operator[])
                  C++ equivalent of StringBuffer/StringBuilder?(C++ 等效于 StringBuffer/StringBuilder?)
                  Adding types to the std namespace(将类型添加到 std 命名空间)
                  Is the C++ std::set thread-safe?(C++ std::set 线程安全吗?)
                  How to use std::find/std::find_if with a vector of custom class objects?(如何将 std::find/std::find_if 与自定义类对象的向量一起使用?)

                  <small id='AK5Ay'></small><noframes id='AK5Ay'>

                      <tbody id='AK5Ay'></tbody>
                    <legend id='AK5Ay'><style id='AK5Ay'><dir id='AK5Ay'><q id='AK5Ay'></q></dir></style></legend><tfoot id='AK5Ay'></tfoot>

                        <bdo id='AK5Ay'></bdo><ul id='AK5Ay'></ul>

                          <i id='AK5Ay'><tr id='AK5Ay'><dt id='AK5Ay'><q id='AK5Ay'><span id='AK5Ay'><b id='AK5Ay'><form id='AK5Ay'><ins id='AK5Ay'></ins><ul id='AK5Ay'></ul><sub id='AK5Ay'></sub></form><legend id='AK5Ay'></legend><bdo id='AK5Ay'><pre id='AK5Ay'><center id='AK5Ay'></center></pre></bdo></b><th id='AK5Ay'></th></span></q></dt></tr></i><div id='AK5Ay'><tfoot id='AK5Ay'></tfoot><dl id='AK5Ay'><fieldset id='AK5Ay'></fieldset></dl></div>