简体   繁体   English

如何在C#中将utf-8转换为cp1252?

[英]How to convert utf-8 to cp1252 in C#?

I need to convert a XML file that is being sent on utf-8 to cp1252. 我需要将在utf-8上发送的XML文件转换为cp1252。 How is this possible? 这怎么可能?

My consumer application only support ANSI characters in it's controls and not Unicode. 我的使用者应用程序的控件中仅支持ANSI字符,而不支持Unicode。 It also does a memcopy of the bytes received. 它还会对收到的字节进行内存复制。

Try the Encoding.Convert method. 尝试使用Encoding.Convert方法。 See here: http://msdn.microsoft.com/en-us/library/kdcak6ye(v=vs.100).aspx 看到这里: http : //msdn.microsoft.com/zh-cn/library/kdcak6ye(v=vs.100).aspx

Got an anwser from jonp from TEAM XAMARIN - http://forums.xamarin.com/discussion/337/how-to-send-byte-encoded-as-ansi 接到jonp的anwser从TEAM XAMARIN - http://forums.xamarin.com/discussion/337/how-to-send-byte-encoded-as-ansi

It turns out "You need to add the West internationalization assemblies to your application.": 结果是“您需要将West国际化程序集添加到您的应用程序。”:

By default, Mono for Android only includes a limited list of collation tables and Encodings. 默认情况下,Mono for Android仅包含有限的排序规则表和编码列表。 In order to include additional data into your application, you can use the MandroidI18n property: West 为了将其他数据包含到您的应用程序中,可以使用MandroidI18n属性:West

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM