資源簡介
nodejs 基于socket.io實現聊天室

代碼片段和文件信息
#!/usr/bin/env?python
import?re
import?json
#?http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
#?http://stackoverflow.com/a/13436167/96656
def?unisymbol(codePoint):
if?codePoint?>=?0x0000?and?codePoint?<=?0xFFFF:
return?unichr(codePoint)
elif?codePoint?>=?0x010000?and?codePoint?<=?0x10FFFF:
highSurrogate?=?int((codePoint?-?0x10000)?/?0x400)?+?0xD800
lowSurrogate?=?int((codePoint?-?0x10000)?%?0x400)?+?0xDC00
return?unichr(highSurrogate)?+?unichr(lowSurrogate)
else:
return?‘Error‘
def?hexify(codePoint):
return?‘U+‘?+?hex(codePoint)[2:].upper().zfill(6)
def?writeFile(filename?contents):
print?filename
with?open(filename?‘w‘)?as?f:
f.write(contents.strip()?+?‘\n‘)
data?=?[]
for?codePoint?in?range(0x000000?0x10FFFF?+?1):
symbol?=?unisymbol(codePoint)
#?http://stackoverflow.com/a/17199950/96656
bytes?=?symbol.encode(‘utf8‘).decode(‘latin1‘)
data.append({
‘codePoint‘:?codePoint
‘decoded‘:?symbol
‘encoded‘:?bytes
});
jsonData?=?json.dumps(data?sort_keys=False?indent=2?separators=(‘‘?‘:?‘))
#?Use?tabs?instead?of?double?spaces?for?indentation
jsonData?=?jsonData.replace(‘??‘?‘\t‘)
#?Escape?hexadecimal?digits?in?escape?sequences
jsonData?=?re.sub(
r‘\\u([a-fA-F0-9]{4})‘
lambda?match:?r‘\u{}‘.format(match.group(1).upper())
jsonData
)
writeFile(‘data.json‘?jsonData)
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????6814??2015-08-04?15:09??chat\app.js
?????文件???????9140??2015-08-03?17:54??chat\node_modules\body-parser\HISTORY.md
?????文件???????2649??2015-08-03?17:54??chat\node_modules\body-parser\index.js
?????文件???????3512??2015-08-03?17:54??chat\node_modules\body-parser\lib\read.js
?????文件???????3608??2015-08-03?17:54??chat\node_modules\body-parser\lib\types\json.js
?????文件???????1847??2015-08-03?17:54??chat\node_modules\body-parser\lib\types\raw.js
?????文件???????2238??2015-08-03?17:54??chat\node_modules\body-parser\lib\types\text.js
?????文件???????5414??2015-08-03?17:54??chat\node_modules\body-parser\lib\types\urlencoded.js
?????文件???????1172??2015-08-03?17:54??chat\node_modules\body-parser\LICENSE
?????文件????????899??2015-08-03?17:54??chat\node_modules\body-parser\node_modules\bytes\History.md
?????文件???????2626??2015-08-03?17:54??chat\node_modules\body-parser\node_modules\bytes\index.js
?????文件???????1680??2015-08-03?17:54??chat\node_modules\body-parser\node_modules\bytes\package.json
?????文件???????2070??2015-08-03?17:54??chat\node_modules\body-parser\node_modules\bytes\Readme.md
?????文件????????196??2015-08-03?17:54??chat\node_modules\body-parser\node_modules\content-type\HISTORY.md
?????文件???????4678??2015-08-03?17:54??chat\node_modules\body-parser\node_modules\content-type\index.js
?????文件???????1089??2015-08-03?17:54??chat\node_modules\body-parser\node_modules\content-type\LICENSE
?????文件???????1767??2015-08-03?17:54??chat\node_modules\body-parser\node_modules\content-type\package.json
?????文件???????2796??2015-08-03?17:54??chat\node_modules\body-parser\node_modules\content-type\README.md
?????文件?????????23??2015-08-03?17:54??chat\node_modules\body-parser\node_modules\debug\.jshintrc
?????文件?????????42??2015-08-03?17:54??chat\node_modules\body-parser\node_modules\debug\.npmignore
?????文件????????480??2015-08-03?17:54??chat\node_modules\body-parser\node_modules\debug\bower.json
?????文件???????3763??2015-08-03?17:54??chat\node_modules\body-parser\node_modules\debug\browser.js
?????文件????????309??2015-08-03?17:54??chat\node_modules\body-parser\node_modules\debug\component.json
?????文件???????4096??2015-08-03?17:54??chat\node_modules\body-parser\node_modules\debug\debug.js
?????文件???????5611??2015-08-03?17:54??chat\node_modules\body-parser\node_modules\debug\History.md
?????文件????????715??2015-08-03?17:54??chat\node_modules\body-parser\node_modules\debug\Makefile
?????文件???????4758??2015-08-03?17:54??chat\node_modules\body-parser\node_modules\debug\node.js
?????文件?????????53??2015-08-03?17:54??chat\node_modules\body-parser\node_modules\debug\node_modules\ms\.npmignore
?????文件???????1307??2015-08-03?17:54??chat\node_modules\body-parser\node_modules\debug\node_modules\ms\History.md
?????文件???????2332??2015-08-03?17:54??chat\node_modules\body-parser\node_modules\debug\node_modules\ms\index.js
............此處省略1636個文件信息
評論
共有 條評論