74
75
76
77
78
79
80
81
82
83
84
|
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
is only in the exporting interfaces to <b>Tcl_DString</b>, also easily remedied. This
module is well within reach of being entirely self contained.
The three private routines are likely good candidates for exporting. They have callers.
In some cases perhaps they are preferred replacements for something already public.
The key flaw here is that the <b>Tcl_UniChar</b> type is too small to hold all the
codepoint values in the Unicode range. This can likely be remedied by just enlarging
codepoint values in the Unicode range (causing Tcl to be restricted to characters in the "Basic Multilingual Plane" (BMP)). This can likely be remedied by just enlarging
the type while still retaining source compatibility. Another idea that's been mentioned is
to just do away with the <b>Tcl_UniChar</b> representation and address the problems
it solves in other ways.
---
Re "Other ways": One idea is to make the 'string rep' not a copy of the bytes in a different format, but some type of index over them, allowing (amortized) O(1) access to all characters despite the vari-length of UTF-8 encoding. While the idea of "ropes" has been thrown about it is not clear if that can be combined with the above or not.
A different idea is to go with "surrogate pairs", where two Tcl_UniChar would represent the characters outside of the BMP.
Neither idea has been fully thought through yet AFAIK (aku).
Re "misleading naming of the internal encoding as utf" ... Our encoding is the same <a href="http://en.wikipedia.org/wiki/UTF-8#Modified_UTF-8">Modified UTF-8</a> used by Java.
Note further that Tcl restricts UTF-8 to a maximum length of 3 bytes. This is in line with our restriction to the BMP. Going beyond the BMP will require us to support UTF-8 to up to 6 characters (AFAIK).
|