-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutf.php
30 lines (29 loc) · 943 Bytes
/
utf.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
require 'utf8_strlen.php';
header("content-type: text/html; charset=utf-8");
$text = $_REQUEST["text"];
$text = preg_replace("/\n|\t+/", " ", $text);
$total_chars = 100;
echo "utfstrlen: " . utf8_strlen($text) . "<br/>";
for ($i=0; $i<=round(($total_chars - utf8_strlen($text)) / utf8_strlen($text)); $i++) {
$new_text .= $text;
}
$text = $new_text;
$width = 10;
$lines = preg_split("/(.{" . $width . "})/u", $new_text, -1, PREG_SPLIT_DELIM_CAPTURE);
foreach($lines as $line) {
if ($line != "") { $real_lines[] = $line; }
}
$lines = $real_lines;
// $lines = preg_split("/.{" . $width . "}/u", -1, PREG_SPLIT_DELIM_CAPTURE);
foreach($lines as $line) {
$chars = preg_split("//u", $line, -1, PREG_SPLIT_DELIM_CAPTURE);
$real_chars = array();
foreach($chars as $char) { if ($char != "") { $real_chars[] = $char; } }
$chars = $real_chars;
foreach($chars as $char) {
echo htmlspecialchars($char);
}
echo "<br/>";
}
?>