-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathfix_encoding_simple.ps1
More file actions
40 lines (30 loc) · 1.45 KB
/
fix_encoding_simple.ps1
File metadata and controls
40 lines (30 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
$sourceFile = "lib\Screens\main_screen_old.dart"
$targetFile = "lib\Screens\main_screen_fixed.dart"
Write-Host "Fixing encoding and copying file..."
# Read the source file with proper encoding
$content = Get-Content $sourceFile -Raw -Encoding UTF8
# Find the end of the first _showSocialSettingsDialog method
$pattern = "void _showSocialSettingsDialog\(BuildContext context\) \{"
$matches = [regex]::Matches($content, $pattern)
if ($matches.Count -gt 1) {
$firstMatch = $matches[0]
$secondMatch = $matches[1]
# Copy from start to end of first method
$firstPart = $content.Substring(0, $secondMatch.Index)
# Find the end of the file
$endPattern = "^\}"
$endMatches = [regex]::Matches($content, $endPattern, [System.Text.RegularExpressions.RegexOptions]::Multiline)
if ($endMatches.Count -gt 0) {
$lastEnd = $endMatches[$endMatches.Count - 1]
$endOfFile = $content.Substring($lastEnd.Index)
# Combine first part and end of file
$cleanContent = $firstPart + $endOfFile
# Save to new file with proper encoding
[System.IO.File]::WriteAllText($targetFile, $cleanContent, [System.Text.Encoding]::UTF8)
Write-Host "Fixed file created: $targetFile"
Write-Host "Original file had $($content.Length) characters"
Write-Host "Fixed file has $($cleanContent.Length) characters"
}
} else {
Write-Host "Could not find duplicate methods"
}