powershell - How can I expand a string variable but escape any special characters within -


let's have array of strings have been pulled in csv file , contents of troublesome strings this:

ps c:\> $line.thestring string` has 'funky'?/ "characters" i'd escape 

how can string while escaping contents of string? i've tried following:

$page.listitem["thestring"] = $line.thestring $page.listitem["thestring"] = @'$line.thestring'@ $page.listitem["thestring"] = $line.thestring $page.listitem["thestring"] = ${line.thestring} $page.listitem["thestring"] = "[regex]::escape($line.thestring)" $page.listitem["thestring"] = "[uri]::escapedatastring($line.thestring)" $page.listitem["thestring"] = "system.management.automation.wildcardpattern]::escape($line.thestring)" 

if text contains: bachelor's degree or equivalent in related subject. when saved page, result looks like: bachelor�s degree or equivalent in related subject. (the � looks square in browser) please point me in right direction?


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -