setcookie ("username",gbk_unicode("张三"));其中gbk_unicode:
function gbk_unicode($text) {
  $rtext = "";
  preg_match_all("/[\x81-\xfe]?./",$text,$regs);
  foreach($regs[0] as $v){
    if(ord($v) > 127) {;
      $rtext .= "&#".base_convert(bin2hex(iconv("gb2312","ucs-2",$v)),16,10).";";
    }else{
      $rtext .= $v;
    }
  }
  return $rtext;
}