Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

Reactor error - core dumped!


devel / comp.lang.tcl / Re: problem/missing/bug in "string length ..."

SubjectAuthor
* problem/missing/bug in "string length ..."aotto1968
+* Re: problem/missing/bug in "string length ..."aotto1968
|`- Re: problem/missing/bug in "string length ..."Gerald Lester
+* Re: problem/missing/bug in "string length ..."Rich
|`* Re: problem/missing/bug in "string length ..."aotto1968
| +- Re: problem/missing/bug in "string length ..."Gerald Lester
| +* Re: problem/missing/bug in "string length ..."saitology9
| |`- Re: problem/missing/bug in "string length ..."Rich
| `* Re: problem/missing/bug in "string length ..."Rich
|  `* Re: problem/missing/bug in "string length ..."aotto1968
|   +- Re: problem/missing/bug in "string length ..."ted@loft.tnolan.com (Ted Nolan
|   `- Re: problem/missing/bug in "string length ..."Gerald Lester
+* Re: problem/missing/bug in "string length ..."Emiliano Gavilan
|`- Re: problem/missing/bug in "string length ..."Luc
`* Re: problem/missing/bug in "string length ..."aotto1968
 `* Re: problem/missing/bug in "string length ..."ted@loft.tnolan.com (Ted Nolan
  `- Re: problem/missing/bug in "string length ..."aotto1968

1
problem/missing/bug in "string length ..."

<us7c8j$3qks9$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13481&group=comp.lang.tcl#13481

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: aotto1968@t-online.de (aotto1968)
Newsgroups: comp.lang.tcl
Subject: problem/missing/bug in "string length ..."
Date: Tue, 5 Mar 2024 16:03:45 +0100
Organization: A noiseless patient Spider
Lines: 64
Message-ID: <us7c8j$3qks9$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 5 Mar 2024 15:03:47 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="8d4f21a091603f34df065a7f653389d4";
logging-data="4019081"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX182DdhE0aFqtqT0IcyPDXtaCTJVWi1070k="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:aEbNnCHOk0DipZhhUFTjRDFW3SM=
Content-Language: en-US
 by: aotto1968 - Tue, 5 Mar 2024 15:03 UTC

Hi,

I use a library to format and print debugging message which use also Linux-terminal color-code.

the CORE problem is that "string length .." is used to format the message and add additional information etc
BUT the "string length .." count the NON-visible color-code as well as visible chars that result in a MISS-format string

example: (color is not visible in this thread !! - but all is "green")

-> outTXT<multi-line>
-> | |DEBUG[1]: aa -> LIST | <- count color codes
-> | |DEBUG[1]: -> | a1 : 111 | <- count color codes
-> | |DEBUG[1]: -> | a2 : 222 | <- count color codes
-> | |DEBUG[1]: -> | a3 : 333 |

a color-code is something like

## ------------------------------------------------------------------------
## DEBUG helper
## Black 0;30 Dark Gray 1;30
## Red 0;31 Light Red 1;31
## Green 0;32 Light Green 1;32
## Brown/Orange 0;33 Yellow 1;33
## Blue 0;34 Light Blue 1;34
## Purple 0;35 Light Purple 1;35
## Cyan 0;36 Light Cyan 1;36
## Light Gray 0;37 White 1;37
##
## 8bit (256) colors: https://stackoverflow.com/questions/4842424/list-of-ansi-color-escape-sequences
variable CL_COLOR
set CL_COLOR(red) "\[1;31m"
set CL_COLOR(green) "\[1;32m"
set CL_COLOR(yellow) "\[1;33m"
set CL_COLOR(blue) "\[1;34m"
set CL_COLOR(purple) "\[38;5;206m"
set CL_COLOR(cyan) "\[1;36m"
set CL_COLOR(lightcyan) "\[38;5;51m"
set CL_COLOR(white) "\[1;37m"
set CL_COLOR(grey) "\[38;5;254m"
set CL_COLOR(orange) "\[38;5;202m"
set CL_COLOR(no) ""
variable CL_RESET "\[0;m"

code:

set tstmsg "$lib_debug::CL_COLOR(red)123$lib_debug::CL_RESET"

puts "$tstmsg"
puts [string length $tstmsg]

result:

123 (the color of "123" is red)
15

there is something MISSING in TCL and this is the "string length ..." only count the !! VISIBLE !! chars

mfg ao

Re: problem/missing/bug in "string length ..."

<us7d6f$3qqbl$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13482&group=comp.lang.tcl#13482

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: aotto1968@t-online.de (aotto1968)
Newsgroups: comp.lang.tcl
Subject: Re: problem/missing/bug in "string length ..."
Date: Tue, 5 Mar 2024 16:19:42 +0100
Organization: A noiseless patient Spider
Lines: 3
Message-ID: <us7d6f$3qqbl$1@dont-email.me>
References: <us7c8j$3qks9$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 5 Mar 2024 15:19:44 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="8d4f21a091603f34df065a7f653389d4";
logging-data="4024693"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/wMnBlFGnllZgdQTP8KYUDIfpR+7jfUpw="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:FqNF803lOcdRqWKURaHpzsK1rVM=
Content-Language: en-US
In-Reply-To: <us7c8j$3qks9$1@dont-email.me>
 by: aotto1968 - Tue, 5 Mar 2024 15:19 UTC

→ add the problem to TCL-wiki also: https://wiki.tcl-lang.org/page/BUG+%2D+%27string+length%27+count+also+NON+visible+chars

Re: problem/missing/bug in "string length ..."

<us7da5$3qpd6$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13483&group=comp.lang.tcl#13483

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: problem/missing/bug in "string length ..."
Date: Tue, 5 Mar 2024 15:21:42 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <us7da5$3qpd6$1@dont-email.me>
References: <us7c8j$3qks9$1@dont-email.me>
Injection-Date: Tue, 5 Mar 2024 15:21:42 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="2bde07d86e2a5ef9419f4a9d3e7926b8";
logging-data="4023718"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX197kbWYaf+IoPP3COa1UmnN"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Cancel-Lock: sha1:KW7C2lr/g15SQ9UJfFDExsIG2TQ=
 by: Rich - Tue, 5 Mar 2024 15:21 UTC

aotto1968 <aotto1968@t-online.de> wrote:
> there is something MISSING in TCL and this is the "string length ..."
> only count the !! VISIBLE !! chars

No. The solution is to measure the string first, then add the terminal
escapes in a lower level, just before output to the terminal.

There is no need to complicate string length with such a requirement,
as it is has not ever been defined as measuring only 'visible'
characters. It has always measured "all" characters in the string.
And it should continue to do so.

All those terminal escapes are simply "characters in the string" which
"increase its length". They only become "invisible" when the string is
output to a device that interprets them in that way. Output them to a
disk file and they appear as bytes in the file.

Secondly, what is "visible" varies depending upon what terminal is used
for output, so making this work for all cases is a deep rabbit hole
with potentially no bottom.

Re: problem/missing/bug in "string length ..."

<uuIFN.527266$xHn7.442567@fx14.iad>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13488&group=comp.lang.tcl#13488

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx14.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: problem/missing/bug in "string length ..."
Content-Language: en-US
Newsgroups: comp.lang.tcl
References: <us7c8j$3qks9$1@dont-email.me> <us7d6f$3qqbl$1@dont-email.me>
From: Gerald.Lester@gmail.com (Gerald Lester)
In-Reply-To: <us7d6f$3qqbl$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 8
Message-ID: <uuIFN.527266$xHn7.442567@fx14.iad>
X-Complaints-To: abuse@fastusenet.org
NNTP-Posting-Date: Tue, 05 Mar 2024 17:19:22 UTC
Organization: fastusenet - www.fastusenet.org
Date: Tue, 5 Mar 2024 11:19:22 -0600
X-Received-Bytes: 1042
 by: Gerald Lester - Tue, 5 Mar 2024 17:19 UTC

On 3/5/24 09:19, aotto1968 wrote:
>
> → add the problem to TCL-wiki also:
> https://wiki.tcl-lang.org/page/BUG+%2D+%27string+length%27+count+also+NON+visible+chars
> Noted in said WIKI page that what characters are visible is *VERY*
device dependent and that this is not something TCL is missing but
rather the application.

Re: problem/missing/bug in "string length ..."

<us7q7q$3tgs4$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13489&group=comp.lang.tcl#13489

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: aotto1968@t-online.de (aotto1968)
Newsgroups: comp.lang.tcl
Subject: Re: problem/missing/bug in "string length ..."
Date: Tue, 5 Mar 2024 20:02:18 +0100
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <us7q7q$3tgs4$1@dont-email.me>
References: <us7c8j$3qks9$1@dont-email.me> <us7da5$3qpd6$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 5 Mar 2024 19:02:18 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="8d4f21a091603f34df065a7f653389d4";
logging-data="4113284"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Nl6WJFj+4Ylv5KFOJhdOIgrC8Yn/IG+c="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:Ry6v+W6deFyM1PQ/EAlVUlnBHIk=
In-Reply-To: <us7da5$3qpd6$1@dont-email.me>
Content-Language: en-US
 by: aotto1968 - Tue, 5 Mar 2024 19:02 UTC

This is funny → it seems to be a "serious" problem to "format" the "terminal-output" with
invisible ctrl-character(s)

I understand that at least a TERM environment variable have to be available to understand
what is a ctrl-char and what is a printing-char.

On 05.03.24 16:21, Rich wrote:
> aotto1968 <aotto1968@t-online.de> wrote:
>> there is something MISSING in TCL and this is the "string length ..."
>> only count the !! VISIBLE !! chars
>
> No. The solution is to measure the string first, then add the terminal
> escapes in a lower level, just before output to the terminal.
>
> There is no need to complicate string length with such a requirement,
> as it is has not ever been defined as measuring only 'visible'
> characters. It has always measured "all" characters in the string.
> And it should continue to do so.
>
> All those terminal escapes are simply "characters in the string" which
> "increase its length". They only become "invisible" when the string is
> output to a device that interprets them in that way. Output them to a
> disk file and they appear as bytes in the file.
>
> Secondly, what is "visible" varies depending upon what terminal is used
> for output, so making this work for all cases is a deep rabbit hole
> with potentially no bottom.

Re: problem/missing/bug in "string length ..."

<jdKFN.66009$9cLc.51516@fx02.iad>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13490&group=comp.lang.tcl#13490

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx02.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: problem/missing/bug in "string length ..."
Content-Language: en-US
Newsgroups: comp.lang.tcl
References: <us7c8j$3qks9$1@dont-email.me> <us7da5$3qpd6$1@dont-email.me>
<us7q7q$3tgs4$1@dont-email.me>
From: Gerald.Lester@gmail.com (Gerald Lester)
In-Reply-To: <us7q7q$3tgs4$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 40
Message-ID: <jdKFN.66009$9cLc.51516@fx02.iad>
X-Complaints-To: abuse@fastusenet.org
NNTP-Posting-Date: Tue, 05 Mar 2024 19:17:35 UTC
Organization: fastusenet - www.fastusenet.org
Date: Tue, 5 Mar 2024 13:17:35 -0600
X-Received-Bytes: 2395
 by: Gerald Lester - Tue, 5 Mar 2024 19:17 UTC

On 3/5/24 13:02, aotto1968 wrote:
>
> This is funny → it seems to be a "serious" problem to "format" the
> "terminal-output" with
> invisible ctrl-character(s)
>
> I understand that at least a TERM environment variable have to be
> available to understand
> what is a ctrl-char and what is a printing-char.

You are making the invalid assumption that all strings only are output
to a terminal -- for most application few if any strings are output to a
terminal. Many times string are just used to send to a socket to
communicate with clients/servers.

>
>
> On 05.03.24 16:21, Rich wrote:
>> aotto1968 <aotto1968@t-online.de> wrote:
>>> there is something MISSING in TCL and this is the "string length ..."
>>> only count the !!  VISIBLE !!  chars
>>
>> No.  The solution is to measure the string first, then add the terminal
>> escapes in a lower level, just before output to the terminal.
>>
>> There is no need to complicate string length with such a requirement,
>> as it is has not ever been defined as measuring only 'visible'
>> characters.  It has always measured "all" characters in the string.
>> And it should continue to do so.
>>
>> All those terminal escapes are simply "characters in the string" which
>> "increase its length".  They only become "invisible" when the string is
>> output to a device that interprets them in that way.  Output them to a
>> disk file and they appear as bytes in the file.
>>
>> Secondly, what is "visible" varies depending upon what terminal is used
>> for output, so making this work for all cases is a deep rabbit hole
>> with potentially no bottom.
>

Re: problem/missing/bug in "string length ..."

<us7vjj$3ukkv$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13491&group=comp.lang.tcl#13491

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: saitology9@gmail.com (saitology9)
Newsgroups: comp.lang.tcl
Subject: Re: problem/missing/bug in "string length ..."
Date: Tue, 5 Mar 2024 15:33:54 -0500
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <us7vjj$3ukkv$1@dont-email.me>
References: <us7c8j$3qks9$1@dont-email.me> <us7da5$3qpd6$1@dont-email.me>
<us7q7q$3tgs4$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 5 Mar 2024 20:33:55 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="69f58dfcd65623b8374926258aff4e23";
logging-data="4149919"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Ig07Y6vqz2ZNrAv4FA69E"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:qmlRXAZgVOBAPW5DlHw2FjOfKe0=
In-Reply-To: <us7q7q$3tgs4$1@dont-email.me>
Content-Language: en-US
 by: saitology9 - Tue, 5 Mar 2024 20:33 UTC

On 3/5/2024 2:02 PM, aotto1968 wrote:
>
> This is funny → it seems to be a "serious" problem to "format" the
> "terminal-output" with
> invisible ctrl-character(s)
>
> I understand that at least a TERM environment variable have to be
> available to understand
> what is a ctrl-char and what is a printing-char.
>
>

[string length] doesn't know about your intentions around how to handle
strings you pass to it. If you want to skip color codes, you can easily
modify your input. string-map is your friend here:

% string length [string map [list $lib_debug::CL_COLOR(red) {}
$lib_debug::CL_COLOR(green) {}
...
$lib_debug::CL_RESET {}] $tstmsg]

This should give you the results you are after.

Re: problem/missing/bug in "string length ..."

<us7vui$3utte$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13492&group=comp.lang.tcl#13492

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: problem/missing/bug in "string length ..."
Date: Tue, 5 Mar 2024 20:39:46 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <us7vui$3utte$1@dont-email.me>
References: <us7c8j$3qks9$1@dont-email.me> <us7da5$3qpd6$1@dont-email.me> <us7q7q$3tgs4$1@dont-email.me> <us7vjj$3ukkv$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 5 Mar 2024 20:39:46 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="2bde07d86e2a5ef9419f4a9d3e7926b8";
logging-data="4159406"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/mZF+vKQU4oH/6jfZbzUGN"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Cancel-Lock: sha1:lLjfceYH/yC4p1vowO+zrfpVRX4=
 by: Rich - Tue, 5 Mar 2024 20:39 UTC

saitology9 <saitology9@gmail.com> wrote:
> On 3/5/2024 2:02 PM, aotto1968 wrote:
>>
>> This is funny → it seems to be a "serious" problem to "format" the
>> "terminal-output" with
>> invisible ctrl-character(s)
>>
>> I understand that at least a TERM environment variable have to be
>> available to understand
>> what is a ctrl-char and what is a printing-char.
>>
>>
>
> [string length] doesn't know about your intentions around how to handle
> strings you pass to it. If you want to skip color codes, you can easily
> modify your input. string-map is your friend here:
>
> % string length [string map [list $lib_debug::CL_COLOR(red) {}
> $lib_debug::CL_COLOR(green) {}
> ...
> $lib_debug::CL_RESET {}] $tstmsg]
>
> This should give you the results you are after.

Or, the OP could measure the string *before* they wrap it with terminal
control characters (which *do* make the string longer) for output to a
terminal.

Re: problem/missing/bug in "string length ..."

<us8043$3utte$2@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13493&group=comp.lang.tcl#13493

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: problem/missing/bug in "string length ..."
Date: Tue, 5 Mar 2024 20:42:43 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 38
Message-ID: <us8043$3utte$2@dont-email.me>
References: <us7c8j$3qks9$1@dont-email.me> <us7da5$3qpd6$1@dont-email.me> <us7q7q$3tgs4$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 5 Mar 2024 20:42:43 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="2bde07d86e2a5ef9419f4a9d3e7926b8";
logging-data="4159406"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19YFUh2U8ayVfDzzPIe4g69"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Cancel-Lock: sha1:x4gPbB8tCvNRviucR2jmTHV1YP0=
 by: Rich - Tue, 5 Mar 2024 20:42 UTC

aotto1968 <aotto1968@t-online.de> wrote:
> On 05.03.24 16:21, Rich wrote:
>> aotto1968 <aotto1968@t-online.de> wrote:
>>> there is something MISSING in TCL and this is the "string length
>>> ..." only count the !! VISIBLE !! chars
>>
>> No. The solution is to measure the string first, then add the
>> terminal escapes in a lower level, just before output to the
>> terminal.
>>
>> All those terminal escapes are simply "characters in the string" which
>> "increase its length". They only become "invisible" when the string is
>> output to a device that interprets them in that way. Output them to a
>> disk file and they appear as bytes in the file.
>>
>> Secondly, what is "visible" varies depending upon what terminal is used
>> for output, so making this work for all cases is a deep rabbit hole
>> with potentially no bottom.
>
> This is funny → it seems to be a "serious" problem to "format" the
> "terminal-output" with invisible ctrl-character(s)
>
> I understand that at least a TERM environment variable have to be
> available to understand what is a ctrl-char and what is a
> printing-char.

There is no way for Tcl to know if you plan to send that string to the
terminal defined by the TERM variable.

You might do that. Or you might send it to a file, or your stdout
might be redirected to a file, or you might send it to a socket and
onward to another machine, where it might be output to a very different
'terminal' from the one where it was created.

If you want string lengths of strings with terminal control sequences
ignored, then simply measure your strings *before* you wrap them with
terminal control sequences.

Re: problem/missing/bug in "string length ..."

<us9epm$amac$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13494&group=comp.lang.tcl#13494

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: aotto1968@t-online.de (aotto1968)
Newsgroups: comp.lang.tcl
Subject: Re: problem/missing/bug in "string length ..."
Date: Wed, 6 Mar 2024 10:59:16 +0100
Organization: A noiseless patient Spider
Lines: 56
Message-ID: <us9epm$amac$1@dont-email.me>
References: <us7c8j$3qks9$1@dont-email.me> <us7da5$3qpd6$1@dont-email.me>
<us7q7q$3tgs4$1@dont-email.me> <us8043$3utte$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 6 Mar 2024 09:59:18 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="92b0121449bbe3f296ac4557ed7ba67e";
logging-data="350540"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18FpiE1XqYSqeQoMb6PAzg1xcz61EV89W0="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:ui0VkvdfWPYQIks0iTjzaECtHAY=
In-Reply-To: <us8043$3utte$2@dont-email.me>
Content-Language: en-US
 by: aotto1968 - Wed, 6 Mar 2024 09:59 UTC

I understand the the default `string length ...` is the wrong place to add this feature
*but* there could be other options.

1. string -visible length "..." or "string -terminal length"
2. or add a "terminal command for all "terminal" related functions like color etc
→ terminal string length "..."
→ terminal color ...
3. your already have such a thing like `string is control ..` or `string is ...` character classes

and yes you can always do a massive code-reorganization to get a simple `string length …` working
without invisible character chars count.

a separate C-library for this task would be good because all other languages seems to have the same "problem"
using the "terminal" proper.

On 05.03.24 21:42, Rich wrote:
> aotto1968 <aotto1968@t-online.de> wrote:
>> On 05.03.24 16:21, Rich wrote:
>>> aotto1968 <aotto1968@t-online.de> wrote:
>>>> there is something MISSING in TCL and this is the "string length
>>>> ..." only count the !! VISIBLE !! chars
>>>
>>> No. The solution is to measure the string first, then add the
>>> terminal escapes in a lower level, just before output to the
>>> terminal.
>>>
>>> All those terminal escapes are simply "characters in the string" which
>>> "increase its length". They only become "invisible" when the string is
>>> output to a device that interprets them in that way. Output them to a
>>> disk file and they appear as bytes in the file.
>>>
>>> Secondly, what is "visible" varies depending upon what terminal is used
>>> for output, so making this work for all cases is a deep rabbit hole
>>> with potentially no bottom.
>>
>> This is funny → it seems to be a "serious" problem to "format" the
>> "terminal-output" with invisible ctrl-character(s)
>>
>> I understand that at least a TERM environment variable have to be
>> available to understand what is a ctrl-char and what is a
>> printing-char.
>
> There is no way for Tcl to know if you plan to send that string to the
> terminal defined by the TERM variable.
>
> You might do that. Or you might send it to a file, or your stdout
> might be redirected to a file, or you might send it to a socket and
> onward to another machine, where it might be output to a very different
> 'terminal' from the one where it was created.
>
> If you want string lengths of strings with terminal control sequences
> ignored, then simply measure your strings *before* you wrap them with
> terminal control sequences.
>

Re: problem/missing/bug in "string length ..."

<l4r94vFppi1U1@mid.individual.net>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13495&group=comp.lang.tcl#13495

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: @ednolan (ted@loft.tnolan.com (Ted Nolan)
Newsgroups: comp.lang.tcl
Subject: Re: problem/missing/bug in "string length ..."
Date: 6 Mar 2024 13:24:47 GMT
Organization: loft
Lines: 31
Message-ID: <l4r94vFppi1U1@mid.individual.net>
References: <us7c8j$3qks9$1@dont-email.me> <us7q7q$3tgs4$1@dont-email.me> <us8043$3utte$2@dont-email.me> <us9epm$amac$1@dont-email.me>
X-Trace: individual.net WOHSeceCijGhFWvWRv0nHAiJP+KIbgPPJIvRhCKL6JGtrWqut+
X-Orig-Path: not-for-mail
Cancel-Lock: sha1:m+1zlaKb10yAnyNUAytHUXyPbcU= sha256:CkhBwgWclds02b98wQQD6SyQd5KVfq3EFB7K5/g9SZY=
X-Newsreader: trn 4.0-test76 (Apr 2, 2001)
 by: ted@loft.tnolan.com - Wed, 6 Mar 2024 13:24 UTC

In article <us9epm$amac$1@dont-email.me>,
aotto1968 <aotto1968@t-online.de> wrote:
>
>I understand the the default `string length ...` is the wrong place to
>add this feature
>*but* there could be other options.
>
>1. string -visible length "..." or "string -terminal length"
>2. or add a "terminal command for all "terminal" related functions like
>color etc
> → terminal string length "..."
> → terminal color ...
>3. your already have such a thing like `string is control ..` or `string
>is ...` character classes
>
>and yes you can always do a massive code-reorganization to get a simple
>`string length …` working
>without invisible character chars count.
>
>a separate C-library for this task would be good because all other
>languages seems to have the same "problem"
>using the "terminal" proper.
>

There is such a C library. It's called "curses"

It appears there is a tcllib package "term" which does similar things,
though I have never tried it.
--
columbiaclosings.com
What's not in Columbia anymore..

Re: problem/missing/bug in "string length ..."

<20240306103441.bc8bf051ed3e85803186d967@example.invalid>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13496&group=comp.lang.tcl#13496

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: emil.g@example.invalid (Emiliano Gavilan)
Newsgroups: comp.lang.tcl
Subject: Re: problem/missing/bug in "string length ..."
Date: Wed, 6 Mar 2024 10:34:41 -0300
Organization: A noiseless patient Spider
Lines: 49
Message-ID: <20240306103441.bc8bf051ed3e85803186d967@example.invalid>
References: <us7c8j$3qks9$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="81b079dc68761d77b85f8392f149e017";
logging-data="481317"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+giDiCU9GyXChiWT+hKVMQUPRkJCGwNRo="
Cancel-Lock: sha1:TDBDpJcwv8bxZYq//UBxgkbGews=
X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu)
 by: Emiliano Gavilan - Wed, 6 Mar 2024 13:34 UTC

On Tue, 5 Mar 2024 16:03:45 +0100
aotto1968 <aotto1968@t-online.de> wrote:

>
> Hi,
>
> I use a library to format and print debugging message which use also Linux-terminal color-code.
>
> the CORE problem is that "string length .." is used to format the message and add additional information etc
> BUT the "string length .." count the NON-visible color-code as well as visible chars that result in a MISS-format string

A simple helper proc is enough:

proc termlen {str} {
string length [regsub -all {\u001b\[[0-9;]+m} $str {}]
}
set CL_COLOR(red) "\u001b\[1;31m"
set CL_RESET "\u001b\[0;m"

set msg "This is a test!!"
set tstmsg $CL_COLOR(red)$msg$CL_RESET
puts $tstmsg

puts "msg length : [string length $msg]"
puts "tstmsg length : [string length $tstmsg]"
puts "termlen : [termlen $tstmsg]"

Output:

This is a test!! (output in red)
msg length : 16
tstmsg length : 28
termlen : 16

Also, be sure that the channel you are writing to is a terminal and no
a regular file; on *nix terminals at least this check works (channels
have a -mode option when the C function isatty(fd) returns true).

proc isterminal {chan} {expr {![catch {chan configure $chan -mode}]}}

~$ tclsh 2>/dev/null
% proc isterminal {chan} {expr {![catch {chan configure $chan -mode}]}}
% isterminal stdout
1 % isterminal stderr
0

--
Emiliano

Re: problem/missing/bug in "string length ..."

<F%_FN.89848$zqTf.57414@fx35.iad>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13497&group=comp.lang.tcl#13497

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx35.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: problem/missing/bug in "string length ..."
Content-Language: en-US
Newsgroups: comp.lang.tcl
References: <us7c8j$3qks9$1@dont-email.me> <us7da5$3qpd6$1@dont-email.me> <us7q7q$3tgs4$1@dont-email.me> <us8043$3utte$2@dont-email.me> <us9epm$amac$1@dont-email.me>
From: Gerald.Lester@gmail.com (Gerald Lester)
In-Reply-To: <us9epm$amac$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 67
Message-ID: <F%_FN.89848$zqTf.57414@fx35.iad>
X-Complaints-To: abuse@fastusenet.org
NNTP-Posting-Date: Wed, 06 Mar 2024 14:23:33 UTC
Organization: fastusenet - www.fastusenet.org
Date: Wed, 6 Mar 2024 08:23:33 -0600
X-Received-Bytes: 3514
 by: Gerald Lester - Wed, 6 Mar 2024 14:23 UTC

On 3/6/24 03:59, aotto1968 wrote:
>
> I understand the the default `string length ...` is the wrong place to
> add this feature
> *but* there could be other options.
>
> 1. string -visible length "..." or "string -terminal length"
> 2. or add a "terminal command for all "terminal" related functions like
> color etc
>    → terminal string length "..."
>    → terminal color ...
> 3. your already have such a thing like `string is control ..` or `string
> is ...` character classes
>
> and yes you can always do a massive code-reorganization to get a simple
> `string length …` working
> without invisible character chars count.
>
> a separate C-library for this task would be good because all other
> languages seems to have the same "problem"
> using the "terminal" proper.

Please feel free to code up and contribute, via a TIP, your suggestions.

>
> On 05.03.24 21:42, Rich wrote:
>> aotto1968 <aotto1968@t-online.de> wrote:
>>> On 05.03.24 16:21, Rich wrote:
>>>> aotto1968 <aotto1968@t-online.de> wrote:
>>>>> there is something MISSING in TCL and this is the "string length
>>>>> ..." only count the !!  VISIBLE !!  chars
>>>>
>>>> No.  The solution is to measure the string first, then add the
>>>> terminal escapes in a lower level, just before output to the
>>>> terminal.
>>>>
>>>> All those terminal escapes are simply "characters in the string" which
>>>> "increase its length".  They only become "invisible" when the string is
>>>> output to a device that interprets them in that way.  Output them to a
>>>> disk file and they appear as bytes in the file.
>>>>
>>>> Secondly, what is "visible" varies depending upon what terminal is used
>>>> for output, so making this work for all cases is a deep rabbit hole
>>>> with potentially no bottom.
>>>
>>> This is funny → it seems to be a "serious" problem to "format" the
>>> "terminal-output" with invisible ctrl-character(s)
>>>
>>> I understand that at least a TERM environment variable have to be
>>> available to understand what is a ctrl-char and what is a
>>> printing-char.
>>
>> There is no way for Tcl to know if you plan to send that string to the
>> terminal defined by the TERM variable.
>>
>> You might do that.  Or you might send it to a file, or your stdout
>> might be redirected to a file, or you might send it to a socket and
>> onward to another machine, where it might be output to a very different
>> 'terminal' from the one where it was created.
>>
>> If you want string lengths of strings with terminal control sequences
>> ignored, then simply measure your strings *before* you wrap them with
>> terminal control sequences.
>>
>

Re: problem/missing/bug in "string length ..."

<20240306165803.2903ca16@lud1.home>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13498&group=comp.lang.tcl#13498

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: luc@sep.invalid (Luc)
Newsgroups: comp.lang.tcl
Subject: Re: problem/missing/bug in "string length ..."
Date: Wed, 6 Mar 2024 16:58:03 -0300
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <20240306165803.2903ca16@lud1.home>
References: <us7c8j$3qks9$1@dont-email.me>
<20240306103441.bc8bf051ed3e85803186d967@example.invalid>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="766e0b8ff93bc00cff4f3ae8f8a201e6";
logging-data="634789"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+HChC2NJ6gq14WyyN8BKiSwjzLQBpq2+I="
Cancel-Lock: sha1:lc/IdMIWfmkc9NN//FKfF07RsrU=
 by: Luc - Wed, 6 Mar 2024 19:58 UTC

This thread reminded me of my movie subtitle program.

Subtitles have a limit on number of characters per line. My program
has to count characters all the time and enforce the limit. And it
turns out that some subtitle formats provide for phrases to be possibly
rendered in italics with run-of-the-mill <i>HTML formatting</i>.

Of course, the HTML tags are not visible on the screen so they must
not be counted.

So my code reads the line into a separate variable, strips the HTML
code and counts the characters in that separate variable.

Seems to be pretty much the same case at hand here.

--
Luc
>>

Re: problem/missing/bug in "string length ..."

<usc1bu$vli2$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13505&group=comp.lang.tcl#13505

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: aotto1968@t-online.de (aotto1968)
Newsgroups: comp.lang.tcl
Subject: Re: problem/missing/bug in "string length ..."
Date: Thu, 7 Mar 2024 10:28:28 +0100
Organization: A noiseless patient Spider
Lines: 112
Message-ID: <usc1bu$vli2$1@dont-email.me>
References: <us7c8j$3qks9$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 7 Mar 2024 09:28:30 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="fc0efbcfbc9162c742c513c1befa7f85";
logging-data="1037890"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/gCLIhDovKwWVn4DwqlD7oEYWY+53UurE="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:l6xbHAeMJZbMi3B6MQYzzPsONZM=
In-Reply-To: <us7c8j$3qks9$1@dont-email.me>
Content-Language: en-US
 by: aotto1968 - Thu, 7 Mar 2024 09:28 UTC

I update the wiki: https://wiki.tcl-lang.org/page/BUG+%2D+%27string+length%27+count+also+NON+visible+chars

update 7 mar 2024
The CORE problem is not just the string length the CORE problem is the representation of the string in tcl

(and all other programming languages as well)
Let's start simple: the problem is just the same as the multibyte-chars-problem raised up ~30 years ago.

at the beginning it was only ascii and a string was char* after a while they figure out that are languages with more chars than
plain ascii.
It took ~20 years to implement utf8 and finally utf16 into all programming languages.
tcl uses utf8 as script-encoding and utf16 internal as string representation because

a string is only useful if index operations can be performt like: string index $str 0 and utf16 is index-able and utf8 not.
The string length problem is not alone, there is also the index-operation-problem like:

string index or
string range or
format %40s
that doesn't work.

The CORE problem is that the terminal-chars are embedded into the string and not as an character attribute.

* the terminal is the main presentation-layer of a tcl. * the gui-toolkit is the main presentation-layer of tk.

The current string length in tcl is doing something in-between string bytelength and string visual-length because
multibyte-chars are reduced to a single-char but invisible console-ctrl-char are counted like a char.

solution
The solution is the same solution like in utf16 or tk. every char have to be presented by a data-structure that hold

the multibyte-char (utf16)
the terminal-encoding (color,bold,underline,...)
I call this utf32

The puts operate as:

connected to a terminal just translate the utf32 string into a stream understood by the terminal.
connected to a file just do a utf32 write into a file
(perhaps the utf32 can be encoded into utf8)
finally you can write a terminal-colored-string into a file and read it again with the color information still available.
I understand that this is not a job for tcl alone because all programming languages are involved and that is the reason I assume
a utf32 consortium is good and programmers of all languages start together to implement this shit.

On 05.03.24 16:03, aotto1968 wrote:
>
> Hi,
>
> I use a library to format and print debugging message which use also Linux-terminal color-code.
>
> the CORE problem is that "string length .." is used to format the message and add additional information etc
> BUT the "string length .." count the NON-visible color-code as well as visible chars that result in a MISS-format string
>
> example: (color is not visible in this thread !! - but all is "green")
>
>  -> outTXT<multi-line>
>  ->   |   |DEBUG[1]: aa   -> LIST                                     |  <- count color codes
>  ->   |   |DEBUG[1]:      ->   | a1                   : 111           |  <- count color codes
>  ->   |   |DEBUG[1]:      ->   | a2                   : 222           |  <- count color codes
>  ->   |   |DEBUG[1]:      ->   | a3                   : 333 |
>
>
> a color-code is something like
>
>   ## ------------------------------------------------------------------------
>   ## DEBUG helper
>   ##  Black        0;30     Dark Gray     1;30
>   ##  Red          0;31     Light Red     1;31
>   ##  Green        0;32     Light Green   1;32
>   ##  Brown/Orange 0;33     Yellow        1;33
>   ##  Blue         0;34     Light Blue    1;34
>   ##  Purple       0;35     Light Purple  1;35
>   ##  Cyan         0;36     Light Cyan    1;36
>   ##  Light Gray   0;37     White         1;37
>   ##
>   ##  8bit (256) colors: https://stackoverflow.com/questions/4842424/list-of-ansi-color-escape-sequences
>   variable CL_COLOR
>   set  CL_COLOR(red)        "\[1;31m"
>   set  CL_COLOR(green)      "\[1;32m"
>   set  CL_COLOR(yellow)     "\[1;33m"
>   set  CL_COLOR(blue)       "\[1;34m"
>   set  CL_COLOR(purple)     "\[38;5;206m"
>   set  CL_COLOR(cyan)       "\[1;36m"
>   set  CL_COLOR(lightcyan)  "\[38;5;51m"
>   set  CL_COLOR(white)      "\[1;37m"
>   set  CL_COLOR(grey)       "\[38;5;254m"
>   set  CL_COLOR(orange)     "\[38;5;202m"
>   set  CL_COLOR(no)         ""
>   variable  CL_RESET        "\[0;m"
>
>
> code:
>
> set tstmsg  "$lib_debug::CL_COLOR(red)123$lib_debug::CL_RESET"
>
> puts "$tstmsg"
> puts [string length $tstmsg]
>
>
> result:
>
> 123        (the color of "123" is red)
> 15
>
>
> there is something MISSING in TCL and this is the "string length ..." only count the !! VISIBLE !! chars
>
>
> mfg ao

Re: problem/missing/bug in "string length ..."

<l4tv2aF7u3iU1@mid.individual.net>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13506&group=comp.lang.tcl#13506

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: @ednolan (ted@loft.tnolan.com (Ted Nolan)
Newsgroups: comp.lang.tcl
Subject: Re: problem/missing/bug in "string length ..."
Date: 7 Mar 2024 13:51:06 GMT
Organization: loft
Lines: 47
Message-ID: <l4tv2aF7u3iU1@mid.individual.net>
References: <us7c8j$3qks9$1@dont-email.me> <usc1bu$vli2$1@dont-email.me>
X-Trace: individual.net 7NSY8k5hrcSQ4NJ7ewCe8QV7S2SmEaSarql+Mi5cuK8+3FFtMc
X-Orig-Path: not-for-mail
Cancel-Lock: sha1:rHedCNmgzlSxnwKDnHoIJEOVEUA= sha256:YdBxnNI4s6hm2DpaWyqIzUlZooAiLqwjV7SAms9FOgM=
X-Newsreader: trn 4.0-test76 (Apr 2, 2001)
 by: ted@loft.tnolan.com - Thu, 7 Mar 2024 13:51 UTC

In article <usc1bu$vli2$1@dont-email.me>,
aotto1968 <aotto1968@t-online.de> wrote:
>I update the wiki:
>https://wiki.tcl-lang.org/page/BUG+%2D+%27string+length%27+count+also+NON+visible+chars
>
>update 7 mar 2024
>The CORE problem is not just the string length the CORE problem is the
>representation of the string in tcl
>
>(and all other programming languages as well)
>Let's start simple: the problem is just the same as the
>multibyte-chars-problem raised up ~30 years ago.
>
>at the beginning it was only ascii and a string was char* after a while
>they figure out that are languages with more chars than
>plain ascii.
>It took ~20 years to implement utf8 and finally utf16 into all
>programming languages.
>tcl uses utf8 as script-encoding and utf16 internal as string
>representation because
>
>a string is only useful if index operations can be performt like: string
>index $str 0 and utf16 is index-able and utf8 not.
>The string length problem is not alone, there is also the
>index-operation-problem like:
>
>string index or
>string range or
>format %40s
>that doesn't work.
>
>The CORE problem is that the terminal-chars are embedded into the string
>and not as an character attribute.
>
>* the terminal is the main presentation-layer of a tcl. * the
>gui-toolkit is the main presentation-layer of tk.
>
the terminal is the main presentation-layer of a tcl

But it's not. At this point, I would guess sockets are the main
"presentation layer", certainly the REST work I have been doing over
the past few years does no terminal I/O. If you want to talk to a
terminal use curses or whatever. That has no relation to the use
cases for files & sockets.
--
columbiaclosings.com
What's not in Columbia anymore..

Re: problem/missing/bug in "string length ..."

<usciem$13aap$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13507&group=comp.lang.tcl#13507

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!usenet.network!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: aotto1968@t-online.de (aotto1968)
Newsgroups: comp.lang.tcl
Subject: Re: problem/missing/bug in "string length ..."
Date: Thu, 7 Mar 2024 15:20:04 +0100
Organization: A noiseless patient Spider
Lines: 61
Message-ID: <usciem$13aap$1@dont-email.me>
References: <us7c8j$3qks9$1@dont-email.me> <usc1bu$vli2$1@dont-email.me>
<l4tv2aF7u3iU1@mid.individual.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 7 Mar 2024 14:20:06 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="fc0efbcfbc9162c742c513c1befa7f85";
logging-data="1157465"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19T52SOKFBwST1wnKGXTn2dEyXv0WXwUHk="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:pFuyvzbGSpejCbytWepZObyfA7M=
Content-Language: en-US
In-Reply-To: <l4tv2aF7u3iU1@mid.individual.net>
 by: aotto1968 - Thu, 7 Mar 2024 14:20 UTC

If you interact with tcl, read/write debugging messages etc it is always a terminal or a gui application.
the "socket" is just like the "file" an other target. I understand that sending "additional-terminal-attributes"
over the socket is *not* a all-day behavior because:

1. you don't use *tcl* for that
2. there is already a *ssh* application
3. there are format(s) like *html* etc which add attributes to strings.

the "terminal-library" as you mentioned does a much but mostly not basic "string-index" operations
because this is the target of the programming language.

→ try to find a [string range $str 17 45] in a curses library etc.

On 07.03.24 14:51, Ted Nolan <tednolan> wrote:
> In article <usc1bu$vli2$1@dont-email.me>,
> aotto1968 <aotto1968@t-online.de> wrote:
>> I update the wiki:
>> https://wiki.tcl-lang.org/page/BUG+%2D+%27string+length%27+count+also+NON+visible+chars
>>
>> update 7 mar 2024
>> The CORE problem is not just the string length the CORE problem is the
>> representation of the string in tcl
>>
>> (and all other programming languages as well)
>> Let's start simple: the problem is just the same as the
>> multibyte-chars-problem raised up ~30 years ago.
>>
>> at the beginning it was only ascii and a string was char* after a while
>> they figure out that are languages with more chars than
>> plain ascii.
>> It took ~20 years to implement utf8 and finally utf16 into all
>> programming languages.
>> tcl uses utf8 as script-encoding and utf16 internal as string
>> representation because
>>
>> a string is only useful if index operations can be performt like: string
>> index $str 0 and utf16 is index-able and utf8 not.
>> The string length problem is not alone, there is also the
>> index-operation-problem like:
>>
>> string index or
>> string range or
>> format %40s
>> that doesn't work.
>>
>> The CORE problem is that the terminal-chars are embedded into the string
>> and not as an character attribute.
>>
>> * the terminal is the main presentation-layer of a tcl. * the
>> gui-toolkit is the main presentation-layer of tk.
>>
> the terminal is the main presentation-layer of a tcl
>
> But it's not. At this point, I would guess sockets are the main
> "presentation layer", certainly the REST work I have been doing over
> the past few years does no terminal I/O. If you want to talk to a
> terminal use curses or whatever. That has no relation to the use
> cases for files & sockets.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor