这是一种编码技术吗?
继ruakh的帖子在这里,我想确定以下代码片段是否属于 TLV 或 KLV 编码类型:
interface
const
Lex_0: string[length('(EOF)')] ='(EOF)';
Lex_1: string[length('(Error)')] ='(Error)';
LexTable : array[0..114] of ^String = (
@Lex_0,
@Lex_1
)
Furhter to ruakh's post here, I want to ascertain wether the following snippet falls into the TLV or KLV encoding type :
interface
const
Lex_0: string[length('(EOF)')] ='(EOF)';
Lex_1: string[length('(Error)')] ='(Error)';
LexTable : array[0..114] of ^String = (
@Lex_0,
@Lex_1
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的示例代码将无法工作,因为您正在混合
shortstring const
和string
的pointer
- 正如 Rob 在他的评论中所述。并且您的代码与 KLV 或 TLV 编码无关。
这里可能是 TLV 编码的示例(我只显示字符串编码,但您可以添加其他类型):
我在这里使用
WideString
因为它可以安全地存储任何 Unicode 内容,即使在 Delphi 2009 之前的版本上也是如此编译器的。您可以使用记录代替我的指针算术:
类似的编码可用于 KLV,但在标头中添加整数键。
Your sample code won't work, as you are mixing
shortstring const
andpointer
ofstring
- as Rob stated in his comment.And your code has nothing to do with KLV nor TLV encoding.
Here may be a sample of TLV encoding (I show only string encoding, but you can add other types):
I used
WideString
here because it can safely store any Unicode content, even on pre-Delphi 2009 version of the compiler.You may use a record instead of my pointer arithmetic:
A similar encoding may be used for KLV, but adding an integer key in the header.
据我所知,这仅定义了两个常量(在本例中为
Lex_0
和Lex_1
),并将它们放入名为LexTable
的数组中,这根本不是编码。然后创建指向字符串的 LexTable 数组,并将两个常量的地址放入该数组中。
As far as I can tell, this only defines two constants (
Lex_0
andLex_1
in this case) and puts them into an array calledLexTable
, this is no encoding at all.then the
LexTable
array of pointers to string is created and addresses of the two constants are put in the array.