Overview
| Artifact ID: | 188d6b6d88fc5cdb9bbdf56582cbbbea03d7495f |
|---|---|
| Ticket: | 3063568fffffffffffffffffffffffffffffffff
regsub example doesn't perform as advertized |
| User & Date: | jaspertheperson on 2010-09-10 11:57:18 |
Changes
- assignee changed to: "pvgoran"
- cmimetype changed to: "text/plain"
- comment changed to:
It's this one: =========================================== Convert all non-ASCII and Tcl-significant characters into \u escape sequences by using regsub and subst in combination: # This RE is just a character class for everything "bad" set RE {[][{};#\\\$\s\u0080-\uffff]} # We will substitute with a fragment of Tcl script in brackets set substitution {[format \\\\u%04x [scan "\\&" %c]]} # Now we apply the substitution to get a subst-string that # will perform the computational parts of the conversion. set quoted [subst [regsub -all $RE $string $substitution]] =========================================== The RE for "bad" characters includes \s which matches all whitespace characters including newline. However, inserting \ before newline before calling subst on a string containing it does not preserve the newline, it causes it to be replaced by a space, so the whole procedure replaces newlines with \u0020 Not sure how to get this to work properly! Little help? - foundin changed to: "obsolete: 8.6b1"
- is_private changed to: "0"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "jaspertheperson"
- subsystem changed to: "43. Regexp"
- title changed to: "regsub example doesn't perform as advertized"
- type changed to: "Bug"