0

enter image description here

function replaceSpecialCharacters($strRemove)
{
    $arrWrapper = @()
    $arrWrapper = $arrWrapper + 1
    $arrWrapper = $arrWrapper + 2

 $arrReplace = @()
 for ($i = 0; $i -lt 95; $i++) 
 { 
    $arrReplace += @($false) 
 }

 $arrReplaceWith=@()
 for ($i = 0; $i -lt 95; $i++) 
 { 
    $arrReplaceWith += @($false) 
 }
 $arrWrapper[0] = $arrReplace
 $arrWrapper[1] = $arrReplace

$arrWrapper[0][0] = "Š"
$arrWrapper[0][1] = "š"
$arrWrapper[0][2) = "Ð"
$arrWrapper[0][3] = "d"
$arrWrapper[0][4] = "Ž"
$arrWrapper[0][5] = "ž"
$arrWrapper[0][6] = "C"
$arrWrapper[0][7] = "c"
$arrWrapper[0][8] = "C"
$arrWrapper[0][9] = "c"
$arrWrapper[0][10] = "À"
$arrWrapper[0][11] = "Á"
$arrWrapper[0][12] = "Â"
$arrWrapper[0][13] = "Ã"
$arrWrapper[0][14] = "Ä"
$arrWrapper[0][15] = "Å"
$arrWrapper[0][16] = "Æ"
$arrWrapper[0][17] = "Ç"
$arrWrapper[0][18] = "È"
$arrWrapper[0][19] = "É"
$arrWrapper[0][20] = "Ê"
$arrWrapper[0][21] = "Ë"
$arrWrapper[0][22] = "Ì"
$arrWrapper[0][23] = "Í"
  $arrWrapper[0][75] = "`"
$arrWrapper[0][76] = "´"
$arrWrapper[0][77] = "„"
$arrWrapper[0][78] = "`"
$arrWrapper[0][79] = "´"
$arrWrapper[0][80] = "€"
$arrWrapper[0][81] = "™"
$arrWrapper[0][82] = "{"
$arrWrapper[0][83] = "}"
$arrWrapper[0][84] = "~"
$arrWrapper[0][85] = "’"
$arrWrapper[0][86] = "'"
$arrWrapper[0][87] = "¶"
$arrWrapper[0][88] = "¼"
$arrWrapper[0][89] = "µ"
$arrWrapper[0][90] = "®"
 }

Hey guys, I want to write a programm where I replace special characters with "normal" characters. Problem: I get an error when I try to save a special charater in powershell. I used this code in vbs and it worked but here I does not work.. Is there any way I can save it?

  • *Which* error? Please post the full error record – Mathias R. Jessen Nov 26 '16 at 17:29
  • If you want to save script in UTF-8 encoding, then script file need to have BOM, or UTF-8 will not be recognized by PowerShell. – user4003407 Nov 26 '16 at 18:01
  • @PetSerAl helped 50/50. There are still characters which causes this exception :/ Like " ' "... In Nodepad I can choose between UTF-8 and UTF-8 without BOM. I choose UTF-8. –  Nov 26 '16 at 18:29
  • @PetSerAl See my Edit 78-85 error... –  Nov 26 '16 at 18:35
  • This is PowerShell double quote characters `"“”„`, so them need to be escaped in double quote string. – user4003407 Nov 26 '16 at 18:40
  • @PetSerAl Which Line? –  Nov 26 '16 at 18:43
  • @Lebron11 `$arrWrapper[0][77] = "„"`, but really, you need to open your script in PowerShell ISE and look for syntax highlighting oddities. You should easy identify where special characters need to be escaped. – user4003407 Nov 26 '16 at 18:48

0 Answers0