Skip to content
Tcl Source Code View Ticket
Login

View Ticket

PRIVATE != CONTROL in Unicode

Closed / Fixedd63061a1ac4003efe490a216757df4fdd36d61aaCreated 3 years agoUpdated 42 days ago
Descriptionwiki2024-01-15 10:44:01
Example:
% string is control \u000A # Unicode category "Cc"
1
% string is control \uE000 # Unicode category "Co"
1
% string is control \uFFFF # Unicode category "Cn"
0
% string is control \uFC00 # Unicode category "Cs"
0

Currently, "string is control" gives "1" if the character is of one of the Unicode categories "Cc" (a C0 or C1 control code), "Cf" (a format control character), "Co" (a private-use character), but not for "Cs" (a surrogate code point) or "Cn" (a reserved unassigned code point or a noncharacter).

Why is "Co" (a private-use character) included? It's not logical: This range is normally used for Glyphs (in e.g. China/Japan) which didn't have an entry assigned yet in an official Unicode version. Normally those are not Control codes.

Therfore, it would be more logical to leave out characters from the "Co" category from the "string is control" implementation.

For Tcl 8.6, this only affects the range from U+E000 - U+F8FF. For Tcl 8.7, it affects the ranges U+F0000 - U+FFFFD and U+100000 - U+10FFFD as well.

Referenced by3
  • 23e01ffee0Merge [123c58d051c8c1ab]: "merge release", "Remove private characters from regexp control table, but add them back in [:cntrl:] class (so no change in regexp handling). Eliminated (size_t) type-casts. Backported from 8.7", and "Fix [d63061a1ac]: PRIVATE != CONTROL in Unicode". check-in2024-08-25 13:22:03
  • 0480bdc823Fix [d63061a1ac]: PRIVATE != CONTROL in Unicode check-in2024-03-03 21:30:39
  • 5219e3ff14Bug [d63061a1ac]: "PRIVATE != CONTROL in Unicode". Leave out "Co" (private-use characters) from "string is control". check-in2024-01-15 10:46:33
jan.nijtmanswiki2024-01-18 07:45:33

This ticket is not important enough to rush into Tcl 8.6.14. I will start dicussion about it after 8.6.14 is released.

But ... if someone (Ashok ....) want to comment on it already, here is the place to do it.

apnadkarniplain2024-01-19 06:14:11
I would agree that Co being classified as a control character does not make sense and should be removed.

Additionally, I have mixed feelings about Cf characters also being classified as control characters. On one hand, I can see why if they are referenced as "format controls". On the other hand, I think most programmers' expectation is that the string is matched against the "traditional" Cc category members. I suppose we can punt that distinction to the future when general Unicode categorization of code points is added to Tcl.
jan.nijtmansplain2024-01-19 12:41:57
> I would agree that Co being classified as a control character does not make sense and should be removed.

Thanks!

> I suppose we can punt that distinction to the future

I'm thinking about "string is Cc", "string is Cf" for this. But it would also
fit into the regexp syntax as \p{Cc} \p{Cf}. See [https://unicode.org/reports/tr18/].
Of course, this would be a hell of a job to implement completely. But starting
with "1.2.5 General Category Property", short form only, would be nice.
jan.nijtmanswiki2024-01-21 16:16:05

See: [3464428]. Looks like Ruby got it 'wrong' too ...

serhiy.storchakawiki2026-10-21 10:03:35

Fixed by [0480bdc823] (in 8.6.15 and 9.0.0): private-use characters (category Co) are no longer string is control. Cc and Cf are unchanged.

serhiy.storchaka Ticket [d63061a1ac]: 3 changes [History diff]2026-10-22 17:19:29
Log in (anonymous is fine) to add a comment.