Spaces:
Running
Running
Download verify_unicode.py from WideChaos/split-boundary-audit: direct link, hf CLI and curl.
- Browser
- Download file 941 Bytes
-
https://huggingface.co/spaces/WideChaos/split-boundary-audit/resolve/main/verify_unicode.py
- Command line
-
hf download hf://spaces/WideChaos/split-boundary-audit/verify_unicode.py
-
curl -L -o verify_unicode.py https://huggingface.co/spaces/WideChaos/split-boundary-audit/resolve/main/verify_unicode.py
941 Bytes
| """Compare browser normalization to Python's explicit original-audit semantics.""" | |
| import json,subprocess,unicodedata | |
| from pathlib import Path | |
| whitespace=[chr(c)for c in range(0x110000)if chr(c).isspace()] | |
| values=[c+'Cafe\u0301'+c+'note'+c for c in whitespace] | |
| values += ['\ufeffBOM kept','\u200bzero width\u200b','\u180eignored?','A\x00B','\ufeff','Cafe\u0301\r\n😀','x\u2028y'] | |
| code="import fs from 'node:fs'; import {normalized} from './planner.mjs'; console.log(JSON.stringify(JSON.parse(fs.readFileSync(0,'utf8')).map(normalized)));" | |
| result=json.loads(subprocess.run(['node','--input-type=module','-e',code],input=json.dumps(values),text=True,capture_output=True,check=True,cwd=Path(__file__).parent).stdout) | |
| assert result==[' '.join(unicodedata.normalize('NFC',s).split())for s in values] | |
| print(json.dumps({'status':'PASS','python_whitespace_codepoints':len(whitespace),'normalization_vectors':len(values),'BOM_not_removed':True})) | |