- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在Bond C# manual ,它注意到以下内容:
These following changes will break wire compatibility and are not recommended:
- Adding or removing required fields
- Incompatible change of field types (any type change not covered above); e.g.: int32 to string, string to wstring
- ...
但它并没有解释为什么。这里的用例是我正在使用将 C# 应用程序与 C++ 后端连接起来的 Bond。该字段当前是一个字符串。我想将它更改为 wstring。手册指出 C# 字符串可以处理 C++ 字符串和 C++ wstrings。因此,为什么我不能将字段类型从字符串更改为 wstring?为什么这个断线兼容?
最佳答案
在 Bond 的二进制格式中,字符串是 UTF8 编码的(无 BOM)而 wstrings 是 UTF16-LE 编码的。如果您要将字段从字符串切换为 wstring,读取端会尝试将 UTF8 数据解释为 UTF16-LE 数据。这两种编码彼此不兼容,因此将字段类型从字符串更改为 wstring 是一个重大更改。
请注意,手册中说“例如 C# string
可以表示 Bond type string
或 wstring
。 “它没有说明任何有关 C++ 类型的信息。当跨 C# 和 C++ 使用 Bond 时,有 三种 类型系统:Bond、C# 和 C++。
如果在 C++ 方面,您想使用类似于 std::wstring
的东西将字段存储在内存中,请看一下使用 Custom type mapping与 string concept .
关于bond - C# 债券 : string to wstring,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51314707/
在Bond C# manual ,它注意到以下内容: These following changes will break wire compatibility and are not recomme
我是一名优秀的程序员,十分优秀!