mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 11:12:36 +01:00
Fix unicode esc string for new json format - thx Filip :)
This commit is contained in:
parent
c8cdf62f7a
commit
d899af729a
@ -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
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user