假设我有一个从CSV文件中提取的字符串数组,麻烦的字符串的内容如下所示:
PS C:\> $line.theString
This string` has 'funky'?/ "characters" that I'd like to escape
如何在转义字符串内容时获取字符串? 我尝试了以下内容:
$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)"
如果文字包含:
Bachelor's degree or equivalent in a related subject.
保存到页面后,我的结果如下:
Bachelor�s degree or equivalent in a related subject.
( 在浏览器中看起来像一个正方形)
你能指点我正确的方向吗?