Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Search and replace for Unicode characters

$
0
0

Hello,

I have a function which searches and replaces characters on file. It works with ASCI sharacters, but not when the strings which needs to be replaced contains Unicode (', 'ā') etc.  The source file is codding utf8 .

$file = "file.txt" 

$SearchReplace = @($file)
#Process files by performing a search and replace
foreach ($file in $SearchReplace) 
{
#Select-Object -Skip 1 |
    (Get-Content $file) | 
        Foreach-object { $_ -replace 'unicode_string' , ';'   } | 
     out-file -encoding Unicode $file
}

How to get working the search (and replace) function with Unicode characters?


Thanks!




Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>