-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
3d3f308
commit 0b7cbdb
Showing
38 changed files
with
120 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* Works in conjuction with auto-generated encoders_data.js | ||
The optimal data structures in that objects are not able to | ||
be generated due to limitations of JSON int key maps, so | ||
first thing is to repack it quick */ | ||
console.log('CHARSET: Repacking encoder data from '+TEXT_ENCODINGS_RAW); | ||
for(let ei=0; ei<TEXT_ENCODINGS_RAW.length; ei++) { | ||
let encoding = TEXT_ENCODINGS_RAW[ei]; | ||
if(encoding.dotnet_name == null) { | ||
console.warn('CHARSET: Encoding had no correspondence: '+encoding.name); | ||
continue | ||
} | ||
if(encoding.codePoints == null || encoding.bytesForCodePoints == null) { | ||
console.error('CHARSET: Encoding failed to provide a map '+encoding.name); | ||
continue; | ||
} | ||
if(encoding.codePoints.length != encoding.bytesForCodePoints.length) { | ||
console.error('CHARSET: Encoding map codepoint/byte count mismatch: '+encoding.name); | ||
continue; | ||
} | ||
encoding.codePointsToBytes = {}; | ||
for(let i=0; i<encoding.codePoints.length; i++) { | ||
encoding.codePointsToBytes[encoding.codePoints[i]] = encoding.bytesForCodePoints[i]; | ||
} | ||
//Clean up large data arrays present in map | ||
encoding.codePoints = null; | ||
encoding.bytesForCodePoints = null; | ||
console.log('CHARSET: Repacked encoding '+encoding.name + ' with aliases '+encoding.aliases); | ||
} | ||
|
||
/* Now map using the alias names. Note here that the encoding | ||
name should NOT be used, because there are instances where | ||
this will create a problem. Browsers map what is called | ||
"iso-8859-1" from the served page to "windows-1252" for | ||
historical reasons. */ | ||
let TEXT_ENCODINGS = {}; | ||
let TEXT_ENCODINGS_COUNT = 0; | ||
for(let ei=0; ei<TEXT_ENCODINGS_RAW.length; ei++) { | ||
let encoding = TEXT_ENCODINGS_RAW[ei]; | ||
for(let ai=0; ai<encoding.aliases.length; ai++) { | ||
let alias = encoding.aliases[ai]; | ||
TEXT_ENCODINGS[alias] = encoding; | ||
TEXT_ENCODINGS_COUNT++; | ||
} | ||
} | ||
|
||
console.log('CHARSET: Repacked '+TEXT_ENCODINGS_COUNT+' encodings.'); |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import http.server | ||
import socketserver | ||
|
||
class CustomHTTPRequestHandler(http.server.SimpleHTTPRequestHandler): | ||
def end_headers(self): | ||
# Override the 'Content-Type' header | ||
self.send_header('Content-Type', 'text/plain') | ||
http.server.SimpleHTTPRequestHandler.end_headers(self) | ||
|
||
def send_header(self, keyword, value): | ||
# Only send headers that are not 'Content-Type' | ||
if keyword.lower() != 'content-type': | ||
super().send_header(keyword, value) | ||
|
||
|
||
if __name__ == "__main__": | ||
PORT = 8000 | ||
handler = CustomHTTPRequestHandler | ||
httpd = socketserver.TCPServer(("", PORT), handler) | ||
print(f"Serving at port {PORT}") | ||
httpd.serve_forever() |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.