QT qToBigEndian空字节问题 [英] QT qToBigEndian Empty bytes problem

查看:404
本文介绍了QT qToBigEndian空字节问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 quint64 value = 0x000001100021ff00; 
quint64 valueTB = qToBigEndian(value);
qDebug()<< QString :: number(valueTB,16);





输出为

 ff210010010000 





为什么要删除初始字节00?



其次是如何用valueTB附加额外的字节。?

解决方案

参见文档 [ ^ ]。


原语中没有00这样的东西类型对象,如整数值。那些领先的00字符只是字符;它们与代表数字的字符串有关,而与数字本身无关。数字00123与123严格相同...



也许您只需要将表示数据的字符串与数据本身混淆。也许你需要更多:学习不要过度使用字符串。所有工作都应该用数据完成,而不是用于表示数据的字符串。例如,可以仅需要字符串作为最终结果,以便在屏幕上显示某些数据。如果你需要这种字符串的特定格式,这是字符串格式的问题,而不是你问题中提到的操作。



-SA

quint64 value = 0x000001100021ff00;
quint64 valueTB = qToBigEndian(value);
qDebug()<<QString::number(valueTB,16);



And output is

ff210010010000



why initial byte "00" is trimmed out??

Second is how I can append extra bytes with valueTB.??

解决方案

See the documentation[^].


There is no such thing as "00" in primitive-type objects such as integer values. Those leading "00" characters are just characters; they are related to strings representing numbers, and not to numbers themselves. The number 00123 is strictly the same as 123…

Perhaps all you need is simply not to mix up strings representing data with data itself. Maybe you need some more: to learn not to overuse strings. All the work should be done with data, not strings representing data. A string can be needed only as a final result, say, for showing some data on screen. If you need certain format for such string, this is a matter of string formatting, not the operations mentioned in your question.

—SA


这篇关于QT qToBigEndian空字节问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆