Path: blob/master/externals/pear-figlet/docs/examples/hello_world.php
13441 views
<?php12/* UTF-8 convert to FIGlet Unicode */3/* iconv PHP module required */4function utf8tofiglet($str)5{6// escape %u7$str = str_replace('%u', sprintf('%%%%u%04X', ord('u')), $str);89if (function_exists('iconv')) {10$str = iconv('utf-8', 'ucs-2be', $str);11$out = '';1213for ($i = 0, $len = strlen($str); $i<$len; $i++) {14$code = ord($str[$i++]) * 256 + ord($str[$i]);1516$out .= $code < 128 ? $str[$i] : sprintf('%%u%04X', $code);17}1819return $out;20}2122return $str;23}2425require_once 'Text/Figlet.php';2627$figlet = new Text_Figlet();28$error = $figlet->LoadFont('makisupa.flf');29if (PEAR::isError($error)) {30echo 'Error: ' . $error->getMessage() . "\n";31} else {32echo $figlet->LineEcho(utf8tofiglet('Hello, world!')) . "\n";33}34?>3536