如何从 ZXing - iPhone 获取原始字节
我有一个大问题。我读过一些帖子,但无法解决这个问题。 我有一个Iphone应用程序,这个应用程序用zxing读取二维码,但是二维码有个人加密。当 ZXing 解析这个字节并转换为 NSString 时,字节发生变化,我无法获取原始字节。
我正在阅读 Decoder.mm 和 ZXing 库的许多其他类,但我无法理解。
有什么想法吗?
谢谢
i have a big problem. I have read some post and can´t solve this problem.
I have a Iphone App, this app read a QR code with zxing, but the QR have a personal encryptation. When ZXing parse this bytes and convert to NSString, the bytes change and i can´t get the originals bytes.
I was reading Decoder.mm and many others classes of ZXing library and i can´t get this.
Any idea?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不幸的是,
ZXWidgetController
和Decoder
类并没有被设置来使这变得简单,并且重构它们以使其变得更容易本身并不是最简单的事情,因为它们最初的方式设计的。如果您想尝试修补某些内容,只需进入
Decoder
类并修改它以获取字节结果,而不是-decode
中的文本结果方法。objc 目录中有一些类可能会使这个特定部分变得更容易,但它们处于较低级别(它们位于 CALayer 级别而不是UIKit 控制器级别)。而且他们没有太多文档。
Unfortunately, the
ZXWidgetController
andDecoder
classes aren't set up to make this easy and refactoring them to make it easier is itself not the easiest thing because of the way they were originally designed.If you wanted to try to patch something in, you just need to go into the
Decoder
class and modify it to grab the byte results instead of the text results in the- decode
method.There are some classes in the
objc
directory that might make this particular part easier but they're at a lower level (they are at theCALayer
level rather than theUIKit
controller level). And they don't have much documentation.好吧...我会回答我自己的问题。你说的是真的,ZXingWidgetController认为返回的char指针是UTF8格式的,并用这个字节创建一个字符串。我做了什么?我需要字符串中每个字节的十六进制值,因此如果 char 68 的十六进制值为 0x57,我制作了一个连接 57|45|25|a7|7e 的字符串......我将十六进制值转换为字符串格式...然后我解析该字符串...这不是一个好的解决方案,但这只是我此时所能做的。
Ok... i will answer my own question. That what you said is true, ZXingWidgetController think that the returned pointer of char is in UTF8 and make a string with this bytes. What i did? I need the Hexadecimal value of each byte in the string, so if the hexa value of the char 68 is 0x57, i made a string concatenating 57|45|25|a7|7e ...... i convert the hexa value into string format... then i parse that string... is not a good solution but is only what i can do at this moments.
对于任何想知道如何做到这一点的人:
我遇到了同样的问题(从二维码获取原始字节):
我“修复”了 DecodedBitStreamParser.cpp 和函数
void DecodedBitStreamParser::decodeByteSegment(..) 以获得十六进制-字符串,例如 ab0cd42...
我将函数末尾的行替换
为:
For anyone wanting to know, how to do that:
I had the same problem (getting raw bytes from the qr-code):
I "fixed" DecodedBitStreamParser.cpp and function
void DecodedBitStreamParser::decodeByteSegment(..) to get a hex-string e.g. ab0cd42...
I replaced the line at the end of the function:
with: