Skip to content

ConvertTo DifferenceString

viscalyxbot edited this page Aug 25, 2024 · 1 revision

ConvertTo-DifferenceString

SYNOPSIS

Converts two strings into a difference string, highlighting the differences between them.

SYNTAX

ConvertTo-DifferenceString [-ReferenceString] <String> [-DifferenceString] <String>
 [[-EqualIndicator] <String>] [[-NotEqualIndicator] <String>] [[-HighlightStart] <String>]
 [[-HighlightEnd] <String>] [[-ReferenceLabel] <String>] [[-DifferenceLabel] <String>] [-NoColumnHeader]
 [-NoLabels] [[-ReferenceLabelAnsi] <String>] [[-DifferenceLabelAnsi] <String>] [[-ColumnHeaderAnsi] <String>]
 [[-ColumnHeaderResetAnsi] <String>] [[-EncodingType] <String>] 
 [<CommonParameters>]

DESCRIPTION

The ConvertTo-DifferenceString command takes two strings, a reference string and a difference string, and converts them into a difference string that highlights the differences between the two strings. The function compares the byte values of each character in the strings and outputs the differences in a formatted manner. It supports customizing the indicators, labels, colors, and encoding type.

EXAMPLES

EXAMPLE 1

ConvertTo-DifferenceString -ReferenceString 'Hello' -DifferenceString 'Hallo'

Expected: But was:


Bytes Ascii Bytes Ascii


48 65 6C 6C 6F Hello == 48 61 6C 6C 6F Hallo

Converts the reference string 'Hello' and the difference string 'Hallo' into a difference string, highlighting the differences.

PARAMETERS

-ColumnHeaderAnsi

Specifies the ANSI escape sequence to apply to the column header.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 11
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ColumnHeaderResetAnsi

Specifies the ANSI escape sequence to reset the column header.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 12
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-DifferenceLabel

Specifies the label for the difference string. Default is 'But was:'.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 8
Default value: But was:
Accept pipeline input: False
Accept wildcard characters: False

-DifferenceLabelAnsi

Specifies the ANSI escape sequence to apply to the difference label.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 10
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-DifferenceString

Specifies the difference string to compare.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-EncodingType

Specifies the encoding type to use for converting the strings to byte arrays. Default is 'UTF8'.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 13
Default value: UTF8
Accept pipeline input: False
Accept wildcard characters: False

-EqualIndicator

Specifies the indicator to use for equal bytes. Default is '=='.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 3
Default value: ==
Accept pipeline input: False
Accept wildcard characters: False

-HighlightEnd

Specifies the ANSI escape sequence to end highlighting. Default is "[0m" (reset color).

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 6
Default value: [0m
Accept pipeline input: False
Accept wildcard characters: False

-HighlightStart

Specifies the ANSI escape sequence to start highlighting. Default is "[31m" (red color).

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 5
Default value: [31m
Accept pipeline input: False
Accept wildcard characters: False

-NoColumnHeader

Specifies whether to exclude the column header from the output.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-NoLabels

Specifies whether to exclude the labels from the output.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-NotEqualIndicator

Specifies the indicator to use for not equal bytes. Default is '!='.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 4
Default value: !=
Accept pipeline input: False
Accept wildcard characters: False

-ReferenceLabel

Specifies the label for the reference string. Default is 'Expected:'.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 7
Default value: Expected:
Accept pipeline input: False
Accept wildcard characters: False

-ReferenceLabelAnsi

Specifies the ANSI escape sequence to apply to the reference label.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 9
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ReferenceString

Specifies the reference string to compare against.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

None.

OUTPUTS

System.String.

NOTES

RELATED LINKS