ReplInFiles with ^c : doesn't paste in UTF-8?

ReplInFiles with ^c : doesn't paste in UTF-8?

8
NewbieNewbie
8

    Oct 23, 2007#1

    Windows XP SP2, UltraEdit version 13.20+2

    Hello,

    I am using this macro to past some content in a file.

    Code: Select all

    InsertMode
    ColumnModeOff
    HexOff
    UnixReOff
    Loop 
    PerlReOn
    ReplInFiles Recursive "C:\pre-process\backup\basic content\" "*.htm" "</tbody></table>"
    "^c"
    Save
    ExitLoop
    EndLoop
    After a checkout of the file I notice that the content from the clipboard that have been paste to the file does not have special characters!

    So the content from the clipboard is corrupted.

    Is there a solution?

    Even when using Unicode ReplInFiles parameter, it doesn't work.

    Thanks.

    6,688586
    Grand MasterGrand Master
    6,688586

      Oct 23, 2007#2

      ReplInFiles does not open the files and determine their format. That's why it is so fast and you can replace a text in hundreds of files within a few seconds.

      That also means that your files are either all real Unicode files (UTF-16 LE) or all real ASCII/ANSI files. UTF-8 files and ASCII escaped Unicode files are not supported directly because ReplInFiles does not determine the format of the files and convert the final replace strings to the format required by the current file. You know that you can also contain parts of a found string in the replace string when using a regular expression.

      Parameter Unicode must be used when all files are UTF-16 LE (BE never tested!). For all other type of files (ASCII, ANSI, UTF-8, ASCII Escaped Unicode) you must have in the clipboard the bytes in ASCII/ANSI as the format of the files need it. Therefore all files must have the same file format or you will create corrupt files with a ReplInFiles command.

      For your specific UTF-8 Replace In Files you have to do following:
      1. Open an existing UTF-8 file or create a new one (in UTF-8) and paste the text with special characters into it.
      2. Save this UTF-8 file and close it.
      3. Open Configuration - File Handling - Unicode/UTF-8 Detection and disable Auto detect UTF-8 files.
      4. Open again the just saved and closed UTF-8 file (recent file list) which is opened now as ASCII/ANSI file.
      5. Select the block just pasted into the file before which contains now the special characters displayed with their UTF-8 codes.
      6. Copy this block into the clipboard.
      7. Run the Replace In Files without the parameter Unicode on your UTF-8 files and they will have the correct encoding for the special characters.
      8. Open again Configuration - File Handling - Unicode/UTF-8 Detection and enable Auto detect UTF-8 files.
      9. Close the UTF-8 file opened as ASCII/ANSI file and re-open it or delete it.
      Last when your replace strings contains line ending characters make sure that all your files where you want to replace something have the same type of line endings. With Replace In Files it is very easy to insert by mistake DOS line endings into a UNIX file and vice versa when not being very careful.

      BTW: The text files with the strings which should be copied into the XML files have hopefully a significant mark like an UTF-8 BOM or an UTF-8 HTML/XML document declaration which allows UltraEdit to detect those txt files as UTF-8 as also the XML files and the HTML files.
      Best regards from an UC/UE/UES for Windows user from Austria

      8
      NewbieNewbie
      8

        Oct 23, 2007#3

        Thank you for sharing your knowledge Mofi.

        It s precious.

        Regards from Belgium.