Re: [whatwg/encoding] Non-normatively visualize the indexes (#89)

zcorpan commented on this pull request.



> +        label += ", Unified Ideograph"
+    elif code_point >= 0xAC00 and code_point <= 0xD7AF:
+        label += ", Hangul"
+    if contiguous:
+        label += ", contiguous"
+    if duplicate:
+        label += ", duplicate"
+    return label
+
+
+def format_code_point(code_point):
+    if code_point >= 0x80 and code_point < 0xA0:
+        # HTML prohibits C1 controls
+        # TODO draw some fancy SVG hex inside the square
+        return "<svg><rect x=1 y=1 width=14 height=14 stroke=black stroke-width=2 fill=none /></svg>"
+    as_str = unichr(code_point)

I get:
```
Traceback (most recent call last):
  File "visualize.py", line 258, in <module>
    format_index(name, row_length, lang, bmp, duplicates, byte_rule)
  File "visualize.py", line 206, in format_index
    out_file.write((u"<td class='%s %s%s%s' aria-label='%s'><dl><dt>%d<dd lang=%s>%s<dd>U+%04X</dl>" % ("contiguous" if contiguous else "discontiguous", classify(code_point), " duplicate" if duplicate else "", check_compatibility(code_point), aria(code_point, contiguous, duplicate), pointer, lang, format_code_point(code_point), code_point)).encode("utf-8"))
  File "visualize.py", line 124, in format_code_point
    as_str = unichr(code_point)
ValueError: unichr() arg not in range(0x10000) (narrow Python build)
```

...with Python 2.7.10

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/encoding/pull/89#pullrequestreview-16985360

Received on Tuesday, 17 January 2017 13:05:03 UTC