File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change 1
1
<!DOCTYPE html>
2
2
< html lang ="en-GB "> <!-- https://github.com/cpp-tutor/pseudocode-compiler/ -->
3
3
< head >
4
- < meta charset =" UTF-8 ">
4
+ < meta http-equiv =" Content-type " content =" text/html;charset= UTF-8 ">
5
5
< title > Pseudocode to JavaScript Compiler</ title >
6
6
< meta name ="viewport " content ="width=device-width, initial-scale=1 ">
7
7
< link href ="pscweb.css " type ="text/css " rel ="stylesheet " />
14
14
< h2 align ="center "> Pseudocode to JavaScript Compiler</ h2 >
15
15
</ div >
16
16
< div class ="window ">
17
- < form id ="input ">
17
+ < form id ="input " accept-charset =" utf-8 " >
18
18
< label for ="program_source_id "> < h3 align ="center "> Type your program in here</ h3 >
19
19
< textarea name ="program_source "> </ textarea >
20
20
</ label >
Original file line number Diff line number Diff line change @@ -36,9 +36,17 @@ function clear_output() {
36
36
document . getElementById ( 'program_output' ) . innerHTML = '' ;
37
37
}
38
38
39
- function base64enc ( rawutf8 ) {
39
+ function toutf8 ( str ) {
40
+ var urifmt = '' + encodeURIComponent ( str ) , x = function ( s ) {
41
+ return String . fromCharCode ( parseInt ( s . substring ( 1 ) , 16 ) ) ;
42
+ }
43
+ return urifmt . replace ( / % ../ g, x ) ;
44
+ }
45
+
46
+ function base64enc ( input ) {
40
47
let encweb = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=' ;
41
- var enc = '' , pos = 0 , len = rawutf8 . length ;
48
+ var rawutf8 = toutf8 ( input ) , enc = '' , pos = 0 ;
49
+ let len = rawutf8 . length ;
42
50
while ( ( len - pos ) > 2 ) {
43
51
enc += encweb [ ( rawutf8 . charCodeAt ( pos ) >> 2 ) & 0x3f ] ;
44
52
enc += encweb [ ( ( rawutf8 . charCodeAt ( pos ) << 4 ) | ( rawutf8 . charCodeAt ( pos + 1 ) >> 4 ) ) & 0x3f ] ;
You can’t perform that action at this time.
0 commit comments