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
9 changes: 1 addition & 8 deletions se5/RemoveUnicodeCharacters/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@ namespace SubtitleEdit.Plugins.RemoveUnicodeCharacters;

public partial class MainWindow : Window
{
/// <summary>Built-in default replacements (used when the user has no persisted setting for a character).</summary>
private static readonly Dictionary<char, string> DefaultReplacements = new()
{
['♪'] = "#",
['♫'] = "#",
};

private readonly PluginRequest _request;
private readonly List<SrtBlock> _blocks;
private readonly Dictionary<string, string> _persistedReplacements;
Expand Down Expand Up @@ -125,7 +118,7 @@ private string ResolveDefaultReplacement(char c)
{
return persisted;
}
return DefaultReplacements.TryGetValue(c, out var builtIn) ? builtIn : string.Empty;
return UnicodeDefaults.Map.TryGetValue(c, out var builtIn) ? builtIn : string.Empty;
}

private void UpdateUiForRows()
Expand Down
69 changes: 69 additions & 0 deletions se5/RemoveUnicodeCharacters/UnicodeDefaults.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using System.Collections.Generic;

namespace SubtitleEdit.Plugins.RemoveUnicodeCharacters;

/// <summary>
/// Built-in suggested replacements for non-ANSI characters that have a near-lossless
/// or universally understood ASCII equivalent. Used as the seed value for the
/// "Replace with" column when the user has no persisted setting for a character.
/// Debatable cases (bullets, arrows, math, trademark, music accidentals) are
/// deliberately omitted - the UI shows them blank so the user picks per row.
/// </summary>
internal static class UnicodeDefaults
{
public static readonly Dictionary<char, string> Map = new()
{
// Smart quotes -> straight ASCII quotes
['‘'] = "'", // ' left single quotation mark
['’'] = "'", // ' right single quotation mark
['‚'] = ",", // ‚ single low-9 quotation mark
['‛'] = "'", // ‛ single high-reversed-9
['“'] = "\"", // " left double quotation mark
['”'] = "\"", // " right double quotation mark
['„'] = "\"", // „ double low-9 quotation mark
['‟'] = "\"", // ‟ double high-reversed-9

// Hyphens / dashes -> hyphen-minus
['‐'] = "-", // ‐ hyphen
['‑'] = "-", // ‑ non-breaking hyphen
['‒'] = "-", // ‒ figure dash
['–'] = "-", // – en dash
['—'] = "-", // — em dash
['―'] = "-", // ― horizontal bar
['−'] = "-", // − minus sign

// Ellipses / dot leaders
['․'] = ".", // ․ one-dot leader
['‥'] = "..", // ‥ two-dot leader
['…'] = "...", // … horizontal ellipsis

// Music notes (note heads, not accidentals)
['♩'] = "#", // ♩ quarter note
['♪'] = "#", // ♪ eighth note
['♫'] = "#", // ♫ beamed eighth notes
['♬'] = "#", // ♬ beamed sixteenth notes

// Wide / narrow space variants -> regular space
[' '] = " ", // en quad
[' '] = " ", // em quad
[' '] = " ", // en space
[' '] = " ", // em space
[' '] = " ", // three-per-em space
[' '] = " ", // four-per-em space
[' '] = " ", // six-per-em space
[' '] = " ", // figure space
[' '] = " ", // punctuation space
[' '] = " ", // thin space
[' '] = " ", // hair space
[' '] = " ", // narrow no-break space
[' '] = " ", // medium mathematical space
[' '] = " ", // ideographic space

// Zero-width and joiner controls -> remove
['​'] = "", // zero-width space
['‌'] = "", // zero-width non-joiner
['‍'] = "", // zero-width joiner
['⁠'] = "", // word joiner
[''] = "", // zero-width no-break space / BOM
};
}
Loading