aotto1968 <
[email protected]> wrote:
Hi,
I use a "format" to get table-like data
puts -nonewline [format {regsub: %-50s -> %-20s : } "$RX" "$RP"]
but get
regsub: [[:space:]]+[[:xdigit:]]+[.] -> XXX. : OK
regsub: [\[]\d+:\d+[\]] -> DDD : KO
the problem seems to be the '\' who are in real '\\'.
my problem is *not* that '\\' is reduced to '\', my problem is that
'%50s' does not really *recognize* the '\\' and does *not* create
final 50-char-string.
*OR*
the '\\' is handled proper by "format" *but* the terminal *eat* the
'\\'. this is a than a problem from 'puts' to encode '\\' into real
'\\'
my encoding is: de_DE.UTF-8
You'll need to post some actual code, that is self contained and
executable, including actual inputs that trigger the issue because
given your description above I can not trigger the problem:
Test code:
#!/usr/bin/tclsh
puts "regsub: [string repeat | 50] -> [string repeat | 20] : "
set RX "qwerty"
set RP "UIOP"
puts [format {regsub: %-50s -> %-20s : } "$RX" "$RP"]
set RX "qwerty \\ \\ \\ \\ qwerty"
set RP "uiop \\ % \$ uiop"
puts [format {regsub: %-50s -> %-20s : } "$RX" "$RP"]
set RX "qwerty \\\\\\\\\\\\\\\\\\\\ qwerty"
set RP "uiop \\\\\\ uiop \\\\"
puts [format {regsub: %-50s -> %-20s : } "$RX" "$RP"]
Test run (note, long lines, but on a monospace display everything
lines up properly):
$ ./tt
regsub: |||||||||||||||||||||||||||||||||||||||||||||||||| -> |||||||||||||||||||| :
regsub: qwerty -> UIOP :
regsub: qwerty \ \ \ \ qwerty -> uiop \ % $ uiop :
regsub: qwerty \\\\\\\\\\ qwerty -> uiop \\\ uiop \\ :
So presence of a backslash in the variable being formatted by the %s
format specifier does not appear to have any impact on the correct
output.
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)