-
Notifications
You must be signed in to change notification settings - Fork 1
/
string to pokemon hex codes.html
60 lines (46 loc) · 1.41 KB
/
string to pokemon hex codes.html
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
<html>
<head>
<title>Pokemon text encoder</title>
<meta charset="UTF-8">
<style>
@font-face {
font-family: "pokemon";
src: url("pokemon_generation_1.woff") format('woff');
}
body {
font-family: pokemon;
}
textarea {
border: 16px solid transparent;
border-image: url("border.png") 16 / 16px / 8px round;
margin: 8px;
font-family: pokemon;
width: 80%;
height:30%;
}
</style>
</head>
<body>
<p>
Convert text to hex values for Pokemon first generation on GameBoy.
</p>
Type text here:<br>
<textarea id="txt"></textarea><br>
Get hexadecimal code here:<br>
<textarea id="hex"></textarea>
<script defer>
var intToHexString = i => i.toString(16)
var charToPokemonCode = c =>
"ABCDEFGHIJKLMNOPQRSTUVWXYE():;[]abcdefghijklmnopqrstuvwxyzé"
.indexOf(c)
+ 0x80
var charToPokemonCodeString = c => intToHexString(charToPokemonCode(c))
var stringToPokemonCodeString = txt =>
Array.prototype.map.call(txt, charToPokemonCodeString)
.join(' ')
txt = document.getElementById('txt')
hex = document.getElementById('hex')
txt.onkeyup = () => hex.value = stringToPokemonCodeString(txt.value)
</script>
</body>
</html>