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
|
* Allow add empty waveform for online videos
|
||||||
* Switch positions of textboxes shortcut - thx Leon/darnn
|
* Switch positions of textboxes shortcut - thx Leon/darnn
|
||||||
* New subtitle format (json, read only) - thx Dvid
|
* New subtitle format (json, read only) - thx Dvid
|
||||||
|
* New subtitle format (json, read only) - thx Filip
|
||||||
* IMPROVED:
|
* IMPROVED:
|
||||||
* Update Bulgarian translation - thx Калин
|
* Update Bulgarian translation - thx Калин
|
||||||
* Update Finish translation - thx Teijo
|
* Update Finish translation - thx Teijo
|
||||||
|
@ -40,18 +40,35 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
|||||||
text = text.Replace("\\n", Environment.NewLine);
|
text = text.Replace("\\n", Environment.NewLine);
|
||||||
bool keepNext = false;
|
bool keepNext = false;
|
||||||
var sb = new StringBuilder(text.Length);
|
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)
|
if (c == '\\' && !keepNext)
|
||||||
{
|
{
|
||||||
keepNext = true;
|
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
|
else
|
||||||
{
|
{
|
||||||
sb.Append(c);
|
sb.Append(c);
|
||||||
keepNext = false;
|
keepNext = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +174,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (startIndex + 3 + tag.Length > s.Length)
|
if (startIndex + 3 + tag.Length > s.Length)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user