Overview
| Artifact ID: | 731ae5f5ce8f7d89af5f324679fa97686b0c4b18 |
|---|---|
| Ticket: | ded7528bffe8bdf4cf5ab9f327b50b207777378e
subst/regsub/format/scan gets confused by braces |
| User & Date: | ericp on 2014-02-16 01:38:06 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/plain"
- comment changed to:
I was trying to write a function that would urlencode a string, with \uxxxx sequences. http://rosettacode.org/wiki/JSON#Tcl led me to trying this code: set escaped1 [subst \ [regsub -all {[\[\]\$\u0000-\u001f\u0080-\uffff]} \ $value2 {[format "\\\\u%04x" [scan {&} %c]]}]] which I thought worked. However, it seems to drop characters when braces are involved: % set value {w1 on the <blah abc {} def > form} w1 on the <blah abc {} def > form % set value1 [string map [list "@" "<@@>"] $value] w1 on the <blah abc {} def > form % set value2 [string map [list "\\" "<@>"] $value1] w1 on the <blah abc {} def > form % set escaped1 [subst [regsub -all {[\[\]\\\{\\\}\$\u0000-\u001f\u0080-\uffff]} $value2 {[format "\\\\u%04x" [scan {&} %c]]}]] w1 on the <blah abc \u007b def > form The close-brace should appear as \u007d, but it's missing completely. Bug, or is there better usage? - foundin changed to: "8.6"
- is_private changed to: "0"
- login: "ericp"
- priority changed to: "5 Medium"
- private_contact changed to: "6d1053e9208f1074fd485c15cc0d7e49e190bac5"
- resolution changed to: "None"
- severity changed to: "Severe"
- status changed to: "Open"
- submitter changed to: "ericp"
- subsystem changed to: "18. Commands M-Z"
- title changed to: "subst/regsub/format/scan gets confused by braces"
- type changed to: "Bug"