From d9eed9f0a7f7279b70d13109f4d3a665481149ed Mon Sep 17 00:00:00 2001 From: Anthony Perkins Date: Mon, 17 Apr 2023 13:04:07 +0100 Subject: [PATCH] Add PowerShell UTF-16 diff --- roles/home-cli/files/gitwindows | 2 ++ roles/home-cli/files/utf16diff.cmd | 3 +++ roles/home-cli/files/utf16diff.ps1 | 3 +++ 3 files changed, 8 insertions(+) create mode 100644 roles/home-cli/files/utf16diff.cmd create mode 100644 roles/home-cli/files/utf16diff.ps1 diff --git a/roles/home-cli/files/gitwindows b/roles/home-cli/files/gitwindows index 47320ac..63e0631 100644 --- a/roles/home-cli/files/gitwindows +++ b/roles/home-cli/files/gitwindows @@ -9,3 +9,5 @@ helper = manager [credential "https://dev.azure.com"] useHttpPath = true +[diff "utf16diff"] + textconv = "C:/Users/anthony.perkins/data/workstation/roles/home-cli/files/utf16diff.cmd" diff --git a/roles/home-cli/files/utf16diff.cmd b/roles/home-cli/files/utf16diff.cmd new file mode 100644 index 0000000..a90dfa9 --- /dev/null +++ b/roles/home-cli/files/utf16diff.cmd @@ -0,0 +1,3 @@ +@ECHO OFF +REM Add "*.ps1 diff=utf16diff" to ~/.config/git/attributes to use this. +powershell.exe -Command "%~dp0\utf16diff.ps1" "%1" diff --git a/roles/home-cli/files/utf16diff.ps1 b/roles/home-cli/files/utf16diff.ps1 new file mode 100644 index 0000000..e56f0f6 --- /dev/null +++ b/roles/home-cli/files/utf16diff.ps1 @@ -0,0 +1,3 @@ +[string]$file = $args[0] +[string]$encoding = $(&"C:\Program Files\Git\usr\bin\file.exe" -b --mime-encoding $file) +&"C:\Program Files\Git\usr\bin\iconv.exe" -c -f $encoding -t UTF-8 $file