Encode text as XML/HTML, escaping all characters outside 7-bit ASCII.
ConvertTo-SafeEntities.ps1 [-InputObject] <String> [-IncludeMarkupChars] [-ProgressAction <ActionPreference>]
[<CommonParameters>]
"$([char]0xD83D)$([char]0xDCA1) File $([char]0x2192) Save" |ConvertTo-SafeEntities.ps1
💡 File → Save
This shows a UTF-16 surrogate pair, used internally by .NET strings, which is combined into a single entity reference.
"ETA: $([char]0xBD) hour" |ConvertTo-SafeEntities.ps1
ETA: ½ hour
An HTML or XML string that may include emoji or other Unicode characters outside the 7-bit ASCII range.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
Indicates that markdown characters should also be escaped.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
https://docs.microsoft.com/dotnet/api/system.char.issurrogatepair
https://docs.microsoft.com/dotnet/api/system.char.converttoutf32