James Stroud wrote: > Micah wrote: > > Hi, > > > > I'm looking for a tool to do the following 2 things: > > > > 1) Given a string (ie. file, std input, whatever), replace all > > whitespace characters with visible characters (like their Unicode value > > or something). The end result will be one long unbroken line > > > > 2) Given a string altered as in step 1, "decode" it back to the > > original string. > > > > Note: The original string (it will usually be source files) might > > already contain Unicode values, and these must remain and not be > > altered in step 2. > > > > Note 2: I'm working in a Windows XP environment, but I have access to > > cygwin if that makes a difference. > > > > Can anyone think of a tool that already does this? I could probably > > whip something up, but if there's already something that does it I'd > > rather just use it. > > > > Micah > > > > Try urllib. > > py> import urllib > py> astr = 'faf\tfasf dsf\ndsfds dsf dsaf \t\r' > py> urllib.quote(astr) > 'faf%09fasf%20dsf%0Adsfds%20dsf%20dsaf%20%09%0D' > py> print astr > faf fasf dsf > dsfds dsf dsaf > > James > > -- > James Stroud > UCLA-DOE Institute for Genomics and Proteomics > Box 951570 > Los Angeles, CA 90095 > > http://www.jamesstroud.com/
Perfect!! Just what I was looking for! -- http://mail.python.org/mailman/listinfo/python-list