Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/externals/pear-figlet/docs/examples/hello_world.php
13441 views
1
<?php
2
3
/* UTF-8 convert to FIGlet Unicode */
4
/* iconv PHP module required */
5
function utf8tofiglet($str)
6
{
7
// escape %u
8
$str = str_replace('%u', sprintf('%%%%u%04X', ord('u')), $str);
9
10
if (function_exists('iconv')) {
11
$str = iconv('utf-8', 'ucs-2be', $str);
12
$out = '';
13
14
for ($i = 0, $len = strlen($str); $i<$len; $i++) {
15
$code = ord($str[$i++]) * 256 + ord($str[$i]);
16
17
$out .= $code < 128 ? $str[$i] : sprintf('%%u%04X', $code);
18
}
19
20
return $out;
21
}
22
23
return $str;
24
}
25
26
require_once 'Text/Figlet.php';
27
28
$figlet = new Text_Figlet();
29
$error = $figlet->LoadFont('makisupa.flf');
30
if (PEAR::isError($error)) {
31
echo 'Error: ' . $error->getMessage() . "\n";
32
} else {
33
echo $figlet->LineEcho(utf8tofiglet('Hello, world!')) . "\n";
34
}
35
?>
36