-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconvertTextToHtml.php
More file actions
70 lines (70 loc) · 3.26 KB
/
convertTextToHtml.php
File metadata and controls
70 lines (70 loc) · 3.26 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!DOCTYPE html>
<html>
<head>
<title>Convert text to HTML</title>
</head>
<body>
<?
include("dbconnect.php");
$articles_str = "SELECT * FROM BookArticleLangs;";
$articles_sql = $mysqli->query($articles_str);
$BookArticleLangID = 0;
$articleText = "";
while ($row = $articles_sql->fetch_assoc())
{
$BookArticleLangID = $row['BookArticleLangID'];
echo $BookArticleLangID . "<br />";
$articleText = $row['BookArticleLangText'];
echo $articleText;
continue;
// Keep &, <, and > in this order first!!!!
$articleText = str_replace(chr(38), "&", $articleText); // &
$articleText = str_replace(chr(60), "<", $articleText); // <
$articleText = str_replace(chr(62), ">", $articleText); // >
$articleText = str_replace("\r\n", "<br />", $articleText);
$articleText = str_replace(chr(9), "	", $articleText);
//$articleText = str_replace(chr(10), " ", $articleText);
$articleText = str_replace(chr(11), "", $articleText);
$articleText = str_replace(chr(12), "", $articleText);
$articleText = str_replace(chr(34), """, $articleText); // "
$articleText = str_replace(chr(39), "'", $articleText); // '
//$articleText = str_replace(chr(13), " ", $articleText);
$articleText = str_replace(chr(138), "Š", $articleText); // Š
$articleText = str_replace(chr(140), "Œ", $articleText); // Œ
$articleText = str_replace(chr(145), "‘", $articleText); // left single quote
$articleText = str_replace(chr(146), "’", $articleText); // right single quote
$articleText = str_replace(chr(147), "“", $articleText); // left double quote
$articleText = str_replace(chr(148), "”", $articleText); // right double quote
$articleText = str_replace(chr(150), "–", $articleText); // – en dash
$articleText = str_replace(chr(151), "—", $articleText); // — em dash
$articleText = str_replace(chr(152), "˜", $articleText); // ˜
$articleText = str_replace(chr(153), "™", $articleText); // ™
$articleText = str_replace(chr(154), "š", $articleText); // š
$articleText = str_replace(chr(156), "œ", $articleText); // œ
$articleText = str_replace(chr(158), "ž", $articleText); // ž
$articleText = str_replace(chr(159), "Ÿ", $articleText); // Ÿ
$articleText = str_replace(chr(162), "¢", $articleText); // ¢
$articleText = str_replace(chr(163), "£", $articleText); // £
$articleText = str_replace(chr(169), "©", $articleText); // ©
$articleText = str_replace(chr(174), "®", $articleText); // ®
$articleText = str_replace(chr(237), "í", $articleText); // í
$articleText = str_replace(chr(252), "ü", $articleText); // ü
// European characters
for ($asciinum = 192; $asciinum <= 255; $asciinum++)
$articleText = str_replace(chr($asciinum), "&#" . $asciinum . ";", $articleText);
/*
$articleText = str_replace(chr(32), " ", $articleText); // space
$articleText = str_replace(chr(402), "ƒ", $articleText); // ƒ
*/
$db_update_str = "UPDATE BookArticleLangs
SET BookArticleLangText = '$articleText'
WHERE BookArticleLangID = " . $BookArticleLangID . ";";
//$mysqli->query($db_update_str);
//echo $articleText;
echo "<br /><br />";
}
$articles_sql->free();
include("dbclose.php")
?>
</body>
</html>