Exemplo n.º 1
0
 /**
  * This method converts the string into the given charset.
  * See Customweb_Core_Charset for more
  * information about the conversion.
  *
  * @param string | Customweb_Core_Charset $charset The target charset.
  * @throws Customweb_Core_Exception_CastException
  * @return Customweb_Core_String
  */
 public function convertTo($charset)
 {
     if (is_string($charset)) {
         $charset = Customweb_Core_Charset::forName($charset);
     } else {
         if (!$charset instanceof Customweb_Core_Charset) {
             throw new Customweb_Core_Exception_CastException('Customweb_Core_Charset');
         }
     }
     $string = Customweb_Core_Charset::convert($this->string, $this->getCharset(), $charset);
     return new Customweb_Core_String($string, $charset, true);
 }