怎么样将字符串转换为特定格式的一种字符串
例: 
 我用gb2312生成了一个字符串,想把它转换为utf8的,怎么办? 
 例:string   test   =    "基本原则sdfasdfasdf23534534 ";   这是在gb2312下生成的一个字符串,怎么把它转换成utf8的编码格式呢?
------解决方案--------------------例:string test =  "基本原则sdfasdfasdf23534534 "; 这是在gb2312下生成的一个字符串,怎么把它转换成utf8的编码格式呢?     
 谁告诉你这是在什么gb2312下生成的一个字符串?!   
 字符串没有编码。
------解决方案--------------------字符串是Unicode编码的
------解决方案--------------------private string Convert(String str) 
  { 
  char[] hexDigits = {  '0 ',  '1 ',  '2 ',  '3 ',  '4 ',  '5 ',  '6 ',  '7 ', 
   '8 ',  '9 ',  'A ',  'B ',  'C ',  'D ',  'E ',  'F '};   
  System.Text.Encoding utf8 = System.Text.Encoding.GetEncoding( "GB2312 ");   
  System.Text.StringBuilder result = new System.Text.StringBuilder();   
  for (int i = 0; i  < str.Length; i++) 
  { 
  string sub = str.Substring(i, 1); 
  byte[] bytes = utf8.GetBytes(sub);   
  if (bytes.Length == 1) //普通英文字母或数字 
  { 
  result.Append(sub); 
  } 
  else //其它字符,转换成为编码 
  { 
  for (int j = 0; j  < bytes.Length; j++) 
  { 
  result.Append( "% " + hexDigits[bytes[j] > >  4] + hexDigits[bytes[j] & 0XF]); 
  } 
  } 
  }   
  return result.ToString(); 
  }
------解决方案--------------------编码要放在字节数组里面 
 转换可以用Encoding.Convert