Skip to content

Commit 805440c

Browse files
authored
Merge pull request #280 from SubtitleEdit/remove-unicode-characters
Add RemoveUnicodeCharacters SE5 plugin
2 parents 2856d03 + befe971 commit 805440c

12 files changed

Lines changed: 812 additions & 0 deletions
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
name: Build RemoveUnicodeCharacters (SE5)
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'se5/RemoveUnicodeCharacters/**'
8+
- 'se5/Plugin-Shared/**'
9+
- '.github/workflows/remove-unicode-characters.yml'
10+
pull_request:
11+
paths:
12+
- 'se5/RemoveUnicodeCharacters/**'
13+
- 'se5/Plugin-Shared/**'
14+
- '.github/workflows/remove-unicode-characters.yml'
15+
workflow_dispatch:
16+
inputs:
17+
release:
18+
description: 'Publish a GitHub release. Bumps the minor in plugin.json and commits it back.'
19+
type: boolean
20+
default: false
21+
version:
22+
description: 'Optional explicit version (e.g. 1.2.0). Overrides the auto-minor-bump.'
23+
required: false
24+
type: string
25+
26+
permissions:
27+
contents: write
28+
29+
jobs:
30+
prepare:
31+
runs-on: ubuntu-latest
32+
outputs:
33+
version: ${{ steps.set.outputs.version }}
34+
tag: ${{ steps.set.outputs.tag }}
35+
ref: ${{ steps.set.outputs.ref }}
36+
release: ${{ steps.set.outputs.release }}
37+
steps:
38+
- name: Checkout
39+
uses: actions/checkout@v4
40+
41+
- name: Resolve version (and bump on release)
42+
id: set
43+
run: |
44+
set -e
45+
current=$(jq -r .version se5/RemoveUnicodeCharacters/plugin.json)
46+
release_flag="false"
47+
ref="${{ github.sha }}"
48+
version="$current"
49+
tag=""
50+
51+
if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ "${{ inputs.release }}" = "true" ]; then
52+
release_flag="true"
53+
if [ -n "${{ inputs.version }}" ]; then
54+
version="${{ inputs.version }}"
55+
else
56+
IFS=. read -r major minor patch <<< "$current"
57+
version="$major.$((minor + 1)).0"
58+
fi
59+
60+
tmp=$(mktemp)
61+
jq --arg v "$version" '.version = $v' se5/RemoveUnicodeCharacters/plugin.json > "$tmp"
62+
mv "$tmp" se5/RemoveUnicodeCharacters/plugin.json
63+
64+
git config user.name "github-actions[bot]"
65+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
66+
git add se5/RemoveUnicodeCharacters/plugin.json
67+
git commit -m "Bump RemoveUnicodeCharacters to $version [skip ci]"
68+
69+
# Retry-with-rebase: if a concurrent release dispatched for a different
70+
# plugin won the push first, pull --rebase and try again.
71+
attempts=0
72+
while ! git push 2>/tmp/push.err; do
73+
attempts=$((attempts + 1))
74+
if [ "$attempts" -ge 5 ]; then
75+
echo "Failed to push after $attempts attempts:" >&2
76+
cat /tmp/push.err >&2
77+
exit 1
78+
fi
79+
echo "Push rejected (attempt $attempts), pulling --rebase and retrying..."
80+
git pull --rebase --no-edit
81+
done
82+
ref=$(git rev-parse HEAD)
83+
84+
IFS=. read -r major minor patch <<< "$version"
85+
tag="se5-remove-unicode-characters-v$major.$minor"
86+
fi
87+
88+
echo "version=$version" >> "$GITHUB_OUTPUT"
89+
echo "tag=$tag" >> "$GITHUB_OUTPUT"
90+
echo "ref=$ref" >> "$GITHUB_OUTPUT"
91+
echo "release=$release_flag" >> "$GITHUB_OUTPUT"
92+
93+
build:
94+
needs: prepare
95+
runs-on: ubuntu-latest
96+
strategy:
97+
fail-fast: false
98+
matrix:
99+
include:
100+
- rid: win-x64
101+
os: windows
102+
exe: RemoveUnicodeCharacters.exe
103+
- rid: win-arm64
104+
os: windows
105+
exe: RemoveUnicodeCharacters.exe
106+
- rid: linux-x64
107+
os: linux
108+
exe: RemoveUnicodeCharacters
109+
- rid: linux-arm64
110+
os: linux
111+
exe: RemoveUnicodeCharacters
112+
- rid: osx-x64
113+
os: macos
114+
exe: RemoveUnicodeCharacters
115+
- rid: osx-arm64
116+
os: macos
117+
exe: RemoveUnicodeCharacters
118+
119+
steps:
120+
- name: Checkout
121+
uses: actions/checkout@v4
122+
with:
123+
ref: ${{ needs.prepare.outputs.ref }}
124+
125+
- name: Setup .NET 8
126+
uses: actions/setup-dotnet@v4
127+
with:
128+
dotnet-version: '8.0.x'
129+
130+
- name: Publish self-contained (${{ matrix.rid }})
131+
working-directory: se5/RemoveUnicodeCharacters
132+
run: |
133+
dotnet publish RemoveUnicodeCharacters.csproj \
134+
-c Release \
135+
-r ${{ matrix.rid }} \
136+
--self-contained true \
137+
-p:DebugType=None \
138+
-p:DebugSymbols=false \
139+
-o staging/RemoveUnicodeCharacters
140+
141+
- name: Rewrite plugin.json for ${{ matrix.os }}
142+
working-directory: se5/RemoveUnicodeCharacters
143+
run: |
144+
jq '
145+
del(.runtime, .entry) |
146+
.executables = { "${{ matrix.os }}": "${{ matrix.exe }}" }
147+
' plugin.json > staging/RemoveUnicodeCharacters/plugin.json
148+
149+
- name: Package zip
150+
working-directory: se5/RemoveUnicodeCharacters/staging
151+
run: zip -r "$GITHUB_WORKSPACE/RemoveUnicodeCharacters-${{ matrix.rid }}.zip" RemoveUnicodeCharacters
152+
153+
- name: Upload artifact
154+
uses: actions/upload-artifact@v4
155+
with:
156+
name: RemoveUnicodeCharacters-${{ matrix.rid }}
157+
path: RemoveUnicodeCharacters-${{ matrix.rid }}.zip
158+
159+
release:
160+
name: Publish GitHub Release
161+
needs: [prepare, build]
162+
if: needs.prepare.outputs.release == 'true'
163+
runs-on: ubuntu-latest
164+
steps:
165+
- name: Download all zips
166+
uses: actions/download-artifact@v4
167+
with:
168+
path: dist
169+
pattern: RemoveUnicodeCharacters-*
170+
merge-multiple: true
171+
172+
- name: Create release and upload zips
173+
env:
174+
GH_TOKEN: ${{ github.token }}
175+
run: |
176+
gh release create "${{ needs.prepare.outputs.tag }}" dist/RemoveUnicodeCharacters-*.zip \
177+
--repo "${{ github.repository }}" \
178+
--target "${{ needs.prepare.outputs.ref }}" \
179+
--title "RemoveUnicodeCharacters v${{ needs.prepare.outputs.version }}" \
180+
--notes "Self-contained RemoveUnicodeCharacters plugin builds for win/linux/osx (x64 + arm64)."

se5-plugins.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,23 @@
8484
"osx-x64": "https://github.com/SubtitleEdit/plugins/releases/download/se5-haxor-v1.1/Haxor-osx-x64.zip",
8585
"osx-arm64": "https://github.com/SubtitleEdit/plugins/releases/download/se5-haxor-v1.1/Haxor-osx-arm64.zip"
8686
}
87+
},
88+
{
89+
"name": "Remove Unicode characters",
90+
"description": "Detects non-ANSI characters in the subtitle and lets you remove or replace each one. Shows a checkable preview with the count and line numbers per character.",
91+
"version": "1.1.0",
92+
"author": "Subtitle Edit",
93+
"url": "https://github.com/SubtitleEdit/plugins/tree/main/se5/RemoveUnicodeCharacters",
94+
"date": "2026-05-26",
95+
"minSeVersion": "5.0.0",
96+
"downloads": {
97+
"win-x64": "https://github.com/SubtitleEdit/plugins/releases/download/se5-remove-unicode-characters-v1.1/RemoveUnicodeCharacters-win-x64.zip",
98+
"win-arm64": "https://github.com/SubtitleEdit/plugins/releases/download/se5-remove-unicode-characters-v1.1/RemoveUnicodeCharacters-win-arm64.zip",
99+
"linux-x64": "https://github.com/SubtitleEdit/plugins/releases/download/se5-remove-unicode-characters-v1.1/RemoveUnicodeCharacters-linux-x64.zip",
100+
"linux-arm64": "https://github.com/SubtitleEdit/plugins/releases/download/se5-remove-unicode-characters-v1.1/RemoveUnicodeCharacters-linux-arm64.zip",
101+
"osx-x64": "https://github.com/SubtitleEdit/plugins/releases/download/se5-remove-unicode-characters-v1.1/RemoveUnicodeCharacters-osx-x64.zip",
102+
"osx-arm64": "https://github.com/SubtitleEdit/plugins/releases/download/se5-remove-unicode-characters-v1.1/RemoveUnicodeCharacters-osx-arm64.zip"
103+
}
87104
}
88105
]
89106
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Application xmlns="https://github.com/avaloniaui"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+
x:Class="SubtitleEdit.Plugins.RemoveUnicodeCharacters.App"
4+
RequestedThemeVariant="Default">
5+
<Application.Styles>
6+
<FluentTheme />
7+
</Application.Styles>
8+
</Application>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using Avalonia.Controls;
2+
using Avalonia.Markup.Xaml;
3+
using SubtitleEdit.Plugins.Shared;
4+
5+
namespace SubtitleEdit.Plugins.RemoveUnicodeCharacters;
6+
7+
public partial class App : PluginApp
8+
{
9+
public override void Initialize() => AvaloniaXamlLoader.Load(this);
10+
11+
protected override Window CreateMainWindow(PluginRequest request) => new MainWindow(request);
12+
}
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<Window xmlns="https://github.com/avaloniaui"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:local="using:SubtitleEdit.Plugins.RemoveUnicodeCharacters"
6+
x:Class="SubtitleEdit.Plugins.RemoveUnicodeCharacters.MainWindow"
7+
mc:Ignorable="d"
8+
Title="Remove Unicode characters"
9+
Width="860" Height="620"
10+
MinWidth="640" MinHeight="400"
11+
WindowStartupLocation="CenterScreen">
12+
<DockPanel Margin="20">
13+
14+
<Grid DockPanel.Dock="Bottom"
15+
ColumnDefinitions="*,Auto,Auto"
16+
Margin="0,14,0,0">
17+
<TextBlock Grid.Column="0"
18+
x:Name="SummaryLabel"
19+
VerticalAlignment="Center"
20+
Opacity="0.75" />
21+
<Button Grid.Column="1"
22+
Content="Cancel"
23+
Click="OnCancel"
24+
MinWidth="100"
25+
Margin="0,0,8,0" />
26+
<Button Grid.Column="2"
27+
x:Name="ApplyButton"
28+
Content="Apply"
29+
Click="OnApply"
30+
MinWidth="100"
31+
Classes="accent"
32+
IsDefault="True" />
33+
</Grid>
34+
35+
<StackPanel Orientation="Horizontal"
36+
DockPanel.Dock="Top"
37+
Spacing="10"
38+
Margin="0,0,0,4">
39+
<Button Content="Select all" Click="OnSelectAll" />
40+
<Button Content="Select none" Click="OnSelectNone" />
41+
<Button Content="Google selected"
42+
Click="OnGoogleSelected"
43+
x:Name="GoogleButton"
44+
IsEnabled="False" />
45+
</StackPanel>
46+
47+
<TextBlock DockPanel.Dock="Top"
48+
FontSize="18"
49+
FontWeight="SemiBold"
50+
Text="Remove Unicode characters" />
51+
52+
<TextBlock DockPanel.Dock="Top"
53+
x:Name="SubtitleLabel"
54+
Margin="0,4,0,12"
55+
Opacity="0.7"
56+
TextWrapping="Wrap" />
57+
58+
<TextBlock DockPanel.Dock="Top"
59+
x:Name="NoCharsLabel"
60+
FontSize="14"
61+
Margin="0,30,0,0"
62+
HorizontalAlignment="Center"
63+
Opacity="0.65"
64+
Text="No Unicode characters found in the selected lines."
65+
IsVisible="False" />
66+
67+
<Border DockPanel.Dock="Top"
68+
x:Name="HeaderBorder"
69+
BorderBrush="#22808080"
70+
BorderThickness="1,1,1,0"
71+
CornerRadius="4,4,0,0"
72+
Padding="4,6"
73+
IsVisible="False">
74+
<Grid ColumnDefinitions="32,92,46,60,200,*">
75+
<TextBlock Grid.Column="1" Text="Code" FontWeight="SemiBold" Opacity="0.7" />
76+
<TextBlock Grid.Column="2" Text="Char" FontWeight="SemiBold" Opacity="0.7" />
77+
<TextBlock Grid.Column="3" Text="Count" FontWeight="SemiBold" Opacity="0.7" />
78+
<TextBlock Grid.Column="4" Text="Replace with" FontWeight="SemiBold" Opacity="0.7" Margin="6,0,0,0" />
79+
<TextBlock Grid.Column="5" Text="Lines" FontWeight="SemiBold" Opacity="0.7" Margin="6,0,0,0" />
80+
</Grid>
81+
</Border>
82+
83+
<Border x:Name="ListBorder"
84+
BorderBrush="#22808080"
85+
BorderThickness="1"
86+
CornerRadius="0,0,4,4"
87+
Padding="0">
88+
<ListBox x:Name="CharsList"
89+
Background="Transparent"
90+
SelectionMode="Single">
91+
<ListBox.ItemTemplate>
92+
<DataTemplate x:DataType="local:UnicodeCharRow">
93+
<Grid ColumnDefinitions="32,92,46,60,200,*" Margin="0,6">
94+
<CheckBox Grid.Column="0"
95+
IsChecked="{Binding Include, Mode=TwoWay}"
96+
VerticalAlignment="Center" />
97+
<TextBlock Grid.Column="1"
98+
Text="{Binding HexCode}"
99+
VerticalAlignment="Center"
100+
FontFamily="Consolas,Menlo,Courier New" />
101+
<TextBlock Grid.Column="2"
102+
Text="{Binding Glyph}"
103+
FontSize="16"
104+
VerticalAlignment="Center" />
105+
<TextBlock Grid.Column="3"
106+
Text="{Binding Count}"
107+
VerticalAlignment="Center"
108+
Opacity="0.8" />
109+
<TextBox Grid.Column="4"
110+
Text="{Binding Replacement, Mode=TwoWay}"
111+
Margin="6,0,8,0"
112+
VerticalAlignment="Center"
113+
Watermark="(remove)" />
114+
<TextBlock Grid.Column="5"
115+
Text="{Binding LinesText}"
116+
VerticalAlignment="Center"
117+
TextWrapping="Wrap"
118+
Opacity="0.7"
119+
FontSize="12" />
120+
</Grid>
121+
</DataTemplate>
122+
</ListBox.ItemTemplate>
123+
</ListBox>
124+
</Border>
125+
</DockPanel>
126+
</Window>

0 commit comments

Comments
 (0)