在asp.net中可以通过下面的代码对字符集进行控制
<globalization
requestEncoding="gb2312"
responseEncoding="gb2312"
/>
但是winform如何来控制字符集呢
c#(winform)默认的字符集是什么?
如何将一个含有中文的字符串转换成gb2312的格式?
<globalization
requestEncoding="gb2312"
responseEncoding="gb2312"
/>
但是winform如何来控制字符集呢
c#(winform)默认的字符集是什么?
如何将一个含有中文的字符串转换成gb2312的格式?
解决方案 »
- 打开EXCEL弹出窗口问题!!在线等高手!!!!!!!!!!!!
- datagridview一个问题
- 如何打包制作好的屏幕保护程序
- jQuery怎么实现checkbox的条件判断
- 如何获取datagridview是否处于编辑状态
- List<我的控件> myCC=new List<我的控件>();这样的东西怎么备份还原啊?
- OwneForm中子窗體激活
- 有关P/Invoke的一个问题.
- 请问,怎么根据控件名称得到这个控件的属性和方法
- C# 操作 Paradox 可读 为什么不可更新、删除???
- 急!!!在windows服务中如何使用定时器
- 我有两个os,A操作系统中装了.net,有没有办法在B操作系统中用A中的msdn?非常感谢(FriendLG)
using System;
using System.Text;namespace ConvertExample
{
class ConvertExampleClass
{
static void Main()
{
string unicodeString = "This string contains the unicode character Pi(\u03a0)"; // Create two different encodings.
Encoding ascii = Encoding.ASCII;
Encoding unicode = Encoding.Unicode; // Convert the string into a byte[].
byte[] unicodeBytes = unicode.GetBytes(unicodeString); // Perform the conversion from one encoding to the other.
byte[] asciiBytes = Encoding.Convert(unicode, ascii, unicodeBytes);
// Convert the new byte[] into a char[] and then into a string.
// This is a slightly different approach to converting to illustrate
// the use of GetCharCount/GetChars.
char[] asciiChars = new char[ascii.GetCharCount(asciiBytes, 0, asciiBytes.Length)];
ascii.GetChars(asciiBytes, 0, asciiBytes.Length, asciiChars, 0);
string asciiString = new string(asciiChars); // Display the strings created before and after the conversion.
Console.WriteLine("Original string: {0}", unicodeString);
Console.WriteLine("Ascii converted string: {0}", asciiString);
}
}
}