1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to search and replace ASCII 160 by ASCII 32 ?

Discussion in 'T&T - TPIPE' started by oph, Jun 29, 2014.

  1. oph

    oph

    Joined:
    Jun 28, 2008
    Messages:
    25
    Likes Received:
    0
    I receive some files with ASCII 160 characters (a acute (á) or unamovible space of Excel). I want to convert to spaces with TPIPE. Is it possible?

    Thanks.

    OPH
     
  2. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,287
    Likes Received:
    39
    Possibly something like this?

    Code:
    tpipe /input=infile.txt /output=outfile.txt /replace=0,0,0,0,0,0,0,0,0,"%@char[160]","%@char[32]"
    
    Nine, count 'em, nine zeros before the search and replace strings. You may also need a /UNICODE= option if either the input file or the output file uses UTF-8 or UTF-16.
     
  3. oph

    oph

    Joined:
    Jun 28, 2008
    Messages:
    25
    Likes Received:
    0
    Thank you.

    I tried

    Code:
    tpipe /input=infile.txt /output=outfile.txt /replace=0,0,0,0,0,0,0,0,0,"á"," "
    but it doesn't work.
     
  4. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,287
    Likes Received:
    39
    Does it work as expected if you use %@CHAR[160] instead of the accented letter? Because I suspect you may be getting bitten by OEM-to-Unicode conversion, somewhere along the line.

    (TCC uses Unicode internally, but characters from a batch file, or e.g. copied from the clipboard, can be in an OEM character set. And the conversions don't always work as you might expect.... And to muddy the waters further, console programs like TCC often use a different OEM character set than graphical programs like the text editor you use to write your batch file! Windows is a mess.)
     
  5. oph

    oph

    Joined:
    Jun 28, 2008
    Messages:
    25
    Likes Received:
    0
    Yes, your solution work. Thank you.

    CHAR[160] can be seen as "á" or as a hard space or as a Beta (double s of German).

    By the way, the files are OEM, I guess, they are as text of emails, surely distorted by the email program.

    A sequence of
    Hexadecimal

    20 20 20 20 20 20.....

    was changed to

    20 A0 20 A0 20 A0.....

    Thank you.
     

Share This Page