Convert to UCS2

后端 未结 4 1725
执念已碎
执念已碎 2020-11-30 10:38

Is there any function in Vb.net (or C#) that encodes a string in UCS2?

Thanks

4条回答
  •  悲&欢浪女
    2020-11-30 11:07

    See Encoding.Unicode.

    Given a .NET String, call Encoding.GetBytes to get a byte array representing that string encoded in UCS2.

    Edit: In the context of System.Text.Encoding, Unicode = UTF-16. As Johannes points out, these are not the same thing in the presence of surrogates.

提交回复
热议问题