Sha256: e24e631d1ca65c3d0da9df6f17fd58e923ea5cd38273cea229f11b8f35172bd2

Contents?: true

Size: 1.32 KB

Versions: 176

Compression:

Stored size: 1.32 KB

Contents

#!/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)

Version data entries

176 entries across 88 versions & 2 rubygems

Version Path
flok-0.0.105 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/utf8/tests/generate-test-data.py
flok-0.0.105 spec/iface/driver/assets/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/tests/generate-test-data.py
flok-0.0.103 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/utf8/tests/generate-test-data.py
flok-0.0.103 spec/iface/driver/assets/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/tests/generate-test-data.py
flok-0.0.102 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/utf8/tests/generate-test-data.py
flok-0.0.102 spec/iface/driver/assets/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/tests/generate-test-data.py
gulp_assets-1.0.0.pre.5 template/node_modules/webpack-dev-server/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/utf8/tests/generate-test-data.py
gulp_assets-1.0.0.pre.5 template/node_modules/webpack-dev-server/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/tests/generate-test-data.py
gulp_assets-1.0.0.pre.4 template/node_modules/webpack-dev-server/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/tests/generate-test-data.py
gulp_assets-1.0.0.pre.4 template/node_modules/webpack-dev-server/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/utf8/tests/generate-test-data.py
gulp_assets-1.0.0.pre.3 template/node_modules/webpack-dev-server/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/utf8/tests/generate-test-data.py
gulp_assets-1.0.0.pre.3 template/node_modules/webpack-dev-server/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/tests/generate-test-data.py
flok-0.0.101 spec/iface/driver/assets/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/tests/generate-test-data.py
flok-0.0.101 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/utf8/tests/generate-test-data.py
flok-0.0.100 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/utf8/tests/generate-test-data.py
flok-0.0.100 spec/iface/driver/assets/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/tests/generate-test-data.py
flok-0.0.99 spec/iface/driver/assets/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/tests/generate-test-data.py
flok-0.0.99 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/utf8/tests/generate-test-data.py
flok-0.0.98 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/utf8/tests/generate-test-data.py
flok-0.0.98 spec/iface/driver/assets/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/tests/generate-test-data.py