|
2012-11-05
| ||
| 21:45 | • Closed ticket [1908077fff]: string trim not trimming Unicode spaces plus 7 o... artifact: 52581e013c user: nijtmans | |
|
2012-10-19
| ||
| 14:22 | • Ticket [1908077fff]: 4 changes artifact: b2d21a7a60 user: nijtmans | |
|
2012-09-23
| ||
| 15:26 | • Ticket [1908077fff]: 4 changes artifact: 81bc6b111c user: nijtmans | |
| 09:17 | • Ticket [1908077fff]: 4 changes artifact: d5761235e4 user: dkf | |
|
2012-09-21
| ||
| 19:14 | • Ticket [1908077fff]: 1 change artifact: f27b12aa02 user: nijtmans | |
|
2008-03-05
| ||
| 15:04 | • New ticket [1908077fff]. artifact: 76b1a695d4 user: escargo | |
string trim not trimming Unicode spaces
Closed / Fixed1908077fffffffffffffffffffffffffffffffffCreated 19 years agoUpdated 14 years ago
Descriptionplain2008-03-05 15:04:50
A string containing a leading Unicode nonbreaking space (\u00A0) did not have that character removed by [string trim ...] (no chars specified for removal). In Unicode there are several "whitespace" characters that [string trim] does not remove by default. (See http://en.wikipedia.org/wiki/Whitespace_%28computer_science%29 for a working definition of white space.) Ironically, [string is space ...] will return 1 for most of these characters, signifying that at some level these characters are known to be spaces. Interestingly, the Unicode NEL (Next Line), \u0085 gets 0 from [string is space \u0085]. So do the following two: U180E MONGOLIAN VOWEL SEPARATOR U205F MEDIUM MATHEMATICAL SPACE There are 3 issues then. [string is space ...] returns the wrong results for certain Unicode characters. [string trim ...] (the form without characters specified) is not deleting Unicode space characters. The documentation for [string trim ...] is not precise about which space characters are deleted (or not deleted). The behavior of [string trim ...] should (in my opinion) be defining as removing those characters for which [string is space .] is 1. If [string trim ...] only trims ASCII white space characters, then they should be explicitly described and listed.
nijtmans Ticket [1908077fff]: 1 change
[History diff]2012-09-21 19:14:09
dkfplain2012-09-23 09:17:29
So, which Unicode character class are you thinking should satisfy the predicate? (I can't quite remember the details, but I do remember that \u0020 and \u00a0 are in different classes; the latter is I believe usually not regarded as a space even though it has a non-printing glyph...)
nijtmansplain2012-09-23 15:26:14
> So, which Unicode character class are you thinking should satisfy the > predicate? I'm not sure yet, but most close would be unicodes "Whitespace" property. See: <http://www.unicode.org/Public/6.1.0/ucd/PropList.txt> The current "string is space" doesn't correspond to the unicode definition of "space" anyway, because CR, LF are not spaces either. "Whitespace" would be more close. Anyway, whatever change, I prefer to do that through a TIP. Adding <0085> could be done without a TIP, but <> But there are more candidates. For example, 200B was considered a space in Unicode 2.1, but not anymore now. http://www.unicode.org/Public/2.1-Update4/PropList-2.1.9.txt
nijtmansplain2012-10-19 14:22:41
See: <http://www.tcl.tk/cgi-bin/tct/tip/413>
nijtmansplain2012-11-05 21:45:38
Fixed in (upcoming) Tcl 8.6
Log in (anonymous is fine) to add a comment.