diff --git a/Changelog.txt b/Changelog.txt index cf1b80336..931210b2e 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -10,6 +10,7 @@ * Allow add empty waveform for online videos * Switch positions of textboxes shortcut - thx Leon/darnn * New subtitle format (json, read only) - thx Dvid + * New subtitle format (json, read only) - thx Filip * IMPROVED: * Update Bulgarian translation - thx Калин * Update Finish translation - thx Teijo diff --git a/src/libse/SubtitleFormats/Json.cs b/src/libse/SubtitleFormats/Json.cs index 95efc3193..dba6fce24 100644 --- a/src/libse/SubtitleFormats/Json.cs +++ b/src/libse/SubtitleFormats/Json.cs @@ -40,18 +40,35 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats text = text.Replace("\\n", Environment.NewLine); bool keepNext = false; var sb = new StringBuilder(text.Length); - foreach (var c in text) + var hexLetters = "01234567890abcdef"; + int i = 0; + while (i < text.Length) { + char c = text[i]; if (c == '\\' && !keepNext) { keepNext = true; + if (i + 6 < text.Length && text[i + 1] == 'u' && + hexLetters.Contains(text[i + 2]) && + hexLetters.Contains(text[i + 3]) && + hexLetters.Contains(text[i + 4]) && + hexLetters.Contains(text[i + 5])) + { + var unicodeString = text.Substring(i, 6); + var unescaped = System.Text.RegularExpressions.Regex.Unescape(unicodeString); + sb.Append(unescaped); + i += 5; + } } else { sb.Append(c); keepNext = false; } + + i++; } + return sb.ToString(); } @@ -157,7 +174,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats return null; } - if (startIndex + 3 + tag.Length > s.Length) + if (startIndex + 3 + tag.Length > s.Length) { return null; }