对字符串使用DataFieldFrameLength [英] Using DataFieldFrameLength with string

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

问题描述

你好

我正在尝试解析utf-8字符串,该字符串前面有1个字节,通过定义结构来指定长度

I am trying to parse a utf-8 string preceded by 1 byte specifying the length by defining a struct

{

UINT8长度;

【DataFieldFrameLength =长度】

【DataFieldFrameLength = Length]

String(2)文本; //utf-8字符串,不以null终止

String(2) Text; // utf-8 string, not null terminated

}

它可以编译,但是在BLOB(Length)有效的情况下,Text字段永远不会被消耗.

it compiles ok, but the field Text is never consumed, while BLOB(Length) works.

由于文本是utf-8字符串,因此我无法找到其他方法来在不使用此属性的情况下将其二进制大小限制为指定值,因此蚂蚁似乎无法按预期工作.

Since the text is a utf-8 string, i cannot find other ways to limit its binary size to a specified value without using this property, ant it does not seem to work as expected.

 

推荐答案

是否可以将String的length参数用于限制长度.

Can you use the length parameter for String to limit the length.

 

{

  UINT8长度;

  UINT8 Length;

 字符串(2,长度)文本;

  String(2, Length) Text;

}

 


这篇关于对字符串使用DataFieldFrameLength的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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