且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

WCF将消息编码从Utf-16更改为Utf-8

更新时间:2022-12-29 20:21:35

您使用哪个绑定来创建通信渠道?CustomBinding中包含的textmessageencoding元素通常包含TextEncoding属性.
https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/wcf/textmessageencoding
WriteEncoding属性指定用于在绑定上发出消息的字符集编码.有效值为

Which binding do you use to create the communication channel? The textmessageencoding element which has been contained in the CustomBinding generally contains TextEncoding property.
https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/wcf/textmessageencoding
WriteEncoding property specifies the character set encoding to be used for emitting messages on the binding. Valid values are

  • UnicodeFffeTextEncoding:Unicode BigEndian编码
  • Utf16TextEncoding:Unicode编码
  • Utf8TextEncoding:8位编码

默认值为Utf8TextEncoding.此属性的类型为Encoding.至于特定的绑定,它也包含textEncoding属性.
https://docs.microsoft.com/en-us/dotnet/api/system.servicemodel.basichttpbinding.textencoding?view=netframework-4.0
随时让我知道是否有什么可以帮助您的.

The default is Utf8TextEncoding. This attribute is of type Encoding. As for the specific binding, it contains the textEncoding property too.
https://docs.microsoft.com/en-us/dotnet/api/system.servicemodel.basichttpbinding.textencoding?view=netframework-4.0
Feel free to let me know if there is anything I can help with.