ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> activetcl
activetcl
Re: [Activetcl] Length of multi-line strings
by Talvo Hornblower other posts by this author
Jul 1 2008 11:28AM messages near this date
view in the new Beta List Site
[Activetcl] Length of multi-line strings | Re: [Activetcl] Length of multi-line strings
Hi Mark,

This works fine for me, in 8.4 and 8.5:

  % set str "a\nb"
  a
  b
  % string length $str
  3
  % string bytelength $str
  3

Are you sure the method you're using to put the string together isn't 
cutting it at the first newline, or something similar? (Can you show us the 
code?)

Regards,
Mike

----- Original Message ----- 
From: "Mark Howe" <mark@[...].com> 
To: <activetcl@[...].com> 
Sent: Tuesday, July 01, 2008 7:11 PM
Subject: [Activetcl] Length of multi-line strings


>  Hi,
> 
>  I have a script that assembles a string that includes several \n. This
>  works fine, except that when I use 'string length' or 'string
>  bytelength' to get its length I get the length of the first line, rather
>  than of the whole string. Am I missing something obvious here (other
>  than that TCL isn't very good at handling newlines)? If not, what's the
>  best workaround? At present, I'm thinking of using a regex to convert
>  all the characters in a copy of the string into a safe character, eg
>  'ZZZZZZZZ...' and then finding the length of that, but surely there is a
>  better way?
> 
>  Regards,
> 
>  Mark Howe
>  _______________________________________________
>  ActiveTcl mailing list
>  ActiveTcl@[...].com
>  To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>  

_______________________________________________
ActiveTcl mailing list
ActiveTcl@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Mark Howe
Talvo Hornblower
Mark Howe

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved