?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_abcdefghijklmnopqrstuvwxyz{|}~"; private static $allowedCharsArray = []; public static function init(){ self::$allowedCharsArray = []; $len = strlen(self::$allowedChars); for($i = 0; $i < $len; ++$i){ self::$allowedCharsArray[self::$allowedChars{$i}] = self::$characterWidths[$i]; } } /** * @deprecated * * @param $text * * @return string */ public static function wrap($text){ $result = ""; $len = strlen($text); $lineWidth = 0; $lineLength = 0; for($i = 0; $i < $len; ++$i){ $char = $text{$i}; if($char === "\n"){ $lineLength = 0; $lineWidth = 0; }elseif(isset(self::$allowedCharsArray[$char])){ $width = self::$allowedCharsArray[$char]; if($lineLength + 1 > self::CHAT_STRING_LENGTH or $lineWidth + $width > self::CHAT_WINDOW_WIDTH){ $result .= "\n"; $lineLength = 0; $lineWidth = 0; } ++$lineLength; $lineWidth += $width; }else{ return $text; } $result .= $char; } return $result; } }