Giter Club home page Giter Club logo

Comments (11)

RichardsATcn avatar RichardsATcn commented on June 2, 2024 1

也许你需要的是显示数字的 int8_t这种类型?但是似乎目前还没有支持,因为担心其与char的兼容性。

是的 我实际需要的是 uint8_t这种类型。 这种类型在和嵌入式设备通信中经常用到。希望能够支持上。

from iguana.

bbbgan avatar bbbgan commented on June 2, 2024

其中char是 0xa1, ascii码数字为161,并不是有效的ASCII码数字。然后 0x11,是17,是控制字符,这些字符不能正常显示也是合理的吧

from iguana.

bbbgan avatar bbbgan commented on June 2, 2024

也许你需要的是显示数字的 int8_t这种类型?但是似乎目前还没有支持,因为担心其与char的兼容性。

from iguana.

RichardsATcn avatar RichardsATcn commented on June 2, 2024

也许你需要的是显示数字的 int8_t这种类型?但是似乎目前还没有支持,因为担心其与char的兼容性。

是的 我实际需要的是 uint8_t这种类型。 这种类型在和嵌入式设备通信中经常用到。希望能够支持上。
关于char 这种数据结构,可以考虑用 类似 hex字符串的形式 。

from iguana.

RichardsATcn avatar RichardsATcn commented on June 2, 2024

其中char是 0xa1, ascii码数字为161,并不是有效的ASCII码数字。然后 0x11,是17,是控制字符,这些字符不能正常显示也是合理的吧

这里应该不只是不能显示。还会导致 输出的字符串不满足json 的规则。无法解析。 或者不支持的情况下,直接跳过或者空。

from iguana.

qicosmos avatar qicosmos commented on June 2, 2024

@RichardsATcn 有其它什么json 库支持这种输出吗?

from iguana.

RichardsATcn avatar RichardsATcn commented on June 2, 2024

@RichardsATcn 有其它什么json 库支持这种输出吗?
目前我也没有找到其他c++的json库支持这种输出。c++的反射获取成本实在太高了。
由于 uint8_t 刚好是8位处理器的一个寄存器长度。 uint8_t这种类型,不仅仅会单个出现,还有会用到 uint8_t data[10]。因为处理器资源的情况。很少使用类似 array动态数组。这种定长的结构体可以直接 通过1字节对齐的方式,直接拷贝内存块获得字节序列,用于传输。
我下面这几种种输出方式都是自己在项目中使用Qt QGadget的反射 配合人工编码获得的。 之所以除了base64 的方式 还用hex的方式,因为嵌入式工程师调试协议时候对 hex会比base64敏感的多。

 uint8_t  u8  =  0x22; // =>  { "U8": "0x22"}
 uint8_t  u8Buf[10] ;// =>  { "U8BUF": "064|base64 str"}
 uint8_t  u8Buf[10] ; // =>  { "U8BUF": "016|AABBCC"} 

from iguana.

bbbgan avatar bbbgan commented on June 2, 2024

我尝试支持一下uint8吧那,如果支持了uint8你的问题可以得到解决了吗?

from iguana.

bbbgan avatar bbbgan commented on June 2, 2024

我刚刚测试了一下,gcc和clang可以区分开int8_t 、uint8_t与char的,windows应该也可以!但是我不知道您的编译器是否可以,

from iguana.

bbbgan avatar bbbgan commented on June 2, 2024

支持了uint8和int8,可以拉取最新的代码试试看

from iguana.

RichardsATcn avatar RichardsATcn commented on June 2, 2024

我刚刚测试了一下,gcc和clang可以区分开int8_t 、uint8_t与char的,windows应该也可以!但是我不知道您的编译器是否可以,

好的,您真是迅速呀。 我的编译器是 vs2019 和 mingw 8.1.0

from iguana.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.