mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 03:02:35 +01:00
Fix json text decode bug - thx darnn :)
This commit is contained in:
parent
710cb31cb7
commit
5068fc65df
23
src/Test/Core/JsonTest.cs
Normal file
23
src/Test/Core/JsonTest.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Nikse.SubtitleEdit.Core.SubtitleFormats;
|
||||
|
||||
namespace Test.Core
|
||||
{
|
||||
[TestClass]
|
||||
public class JsonTest
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestUnicodeFirst()
|
||||
{
|
||||
var result = Json.DecodeJsonText("\u05d1 ");
|
||||
Assert.AreEqual("ב ", result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestUnicodeLast()
|
||||
{
|
||||
var result = Json.DecodeJsonText(" \u05d1");
|
||||
Assert.AreEqual(" ב", result);
|
||||
}
|
||||
}
|
||||
}
|
@ -64,6 +64,7 @@
|
||||
<Compile Include="Assa\ResamplerTest.cs" />
|
||||
<Compile Include="Assa\AssaTimeCodes.cs" />
|
||||
<Compile Include="Core\AudioToTextTest.cs" />
|
||||
<Compile Include="Core\JsonTest.cs" />
|
||||
<Compile Include="Core\MergeShortLinesUtilsTest.cs" />
|
||||
<Compile Include="Core\CsvUtilTest.cs" />
|
||||
<Compile Include="Core\WebVttHelperTest.cs" />
|
||||
|
@ -23,7 +23,7 @@ namespace Nikse.SubtitleEdit.Core.AutoTranslate
|
||||
public void Initialize()
|
||||
{
|
||||
_httpClient = DownloaderFactory.MakeHttpClient();
|
||||
_httpClient.DefaultRequestHeaders.Add("user-agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36");
|
||||
_httpClient.DefaultRequestHeaders.Add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0");
|
||||
_httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json; charset=UTF-8");
|
||||
_httpClient.BaseAddress = new Uri("https://api.mymemory.translated.net/get");
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
if (c == '\\' && !keepNext)
|
||||
{
|
||||
keepNext = true;
|
||||
if (i + 6 < text.Length && text[i + 1] == 'u' &&
|
||||
if (i + 5 < text.Length && text[i + 1] == 'u' &&
|
||||
hexLetters.Contains(text[i + 2]) &&
|
||||
hexLetters.Contains(text[i + 3]) &&
|
||||
hexLetters.Contains(text[i + 4]) &&
|
||||
|
Loading…
Reference in New Issue
Block a user