Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1787,12 +1787,11 @@ internal static char SetDelimiter(PSCmdlet cmdlet, string parameterSetName, char
case "UseCulture":
case "CulturePath":
case "CultureLiteralPath":
if (useCulture)
{
// ListSeparator is apparently always a character even though the property returns a string, checked via:
// [CultureInfo]::GetCultures("AllCultures") | % { ([CultureInfo]($_.Name)).TextInfo.ListSeparator } | ? Length -ne 1
delimiter = CultureInfo.CurrentCulture.TextInfo.ListSeparator[0];
}
// ListSeparator is apparently always a character even though the property returns a string, checked via:
// [CultureInfo]::GetCultures("AllCultures") | % { ([CultureInfo]($_.Name)).TextInfo.ListSeparator } | ? Length -ne 1
delimiter = useCulture
? CultureInfo.CurrentCulture.TextInfo.ListSeparator[0]
: ImportExportCSVHelper.CSVDelimiter;

break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ Describe "ConvertTo-Csv DRT Unit Tests" -Tags "CI" {
$returnObject[2] | Should -BeExactly "`"1`"$($delimiter)`"2`""
}

## https://github.com/PowerShell/PowerShell/issues/26513
It "Test convertto-csv with -UseCulture:`$false uses default comma delimiter" {
$returnObject = $inputObject | ConvertTo-Csv -UseCulture:$false -IncludeTypeInformation
$returnObject.Count | Should -Be 3
$returnObject[0] | Should -BeExactly "#TYPE System.Management.Automation.PSCustomObject"
$returnObject[1] | Should -BeExactly "`"First`",`"Second`""
$returnObject[2] | Should -BeExactly "`"1`",`"2`""
}

It "Test convertto-csv with Delimiter" {
$returnObject = $inputObject | ConvertTo-Csv -Delimiter ";" -IncludeTypeInformation
$returnObject.Count | Should -Be 3
Expand Down