BOM Gone?
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
Esamina Loader.cs, StorageFIleLoader.cs e LottieCompositionReader.cs, iniziando da ReadStreamToUTF8 e NormalizeTextToUTF8 e da come gli stream di FileOpenPicker li raggiungono. Verifica se il percorso del picker rimuove il BOM UTF-8 prima della normalizzazione, quindi rendi coerente la gestione del BOM e verifica che JSON continui a essere caricato correttamente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
The best I can tell, in Lottie-Windows Loader.cs, StorageFIleLoader.cs, LottieCompositionReader.cs there is an effort to process different UTF and non-UTF files:
public static LottieComposition? ReadLottieCompositionFromJsonStream(Stream stream, Options options, out IReadOnlyList<(string Code, string Description)> issues)
{
ReadStreamToUTF8(stream, out var utf8Text);
return ReadLottieCompositionFromJson(utf8Text, options, out issues);
}
static void ReadStreamToUTF8(Stream stream, out ReadOnlySpan<byte> utf8Text)
{
// This buffer size is chosen to be about 50% larger than
// the average file size in our corpus, so most of the time
// we don't need to reallocate and copy.
var buffer = new byte[150000];
var bytesRead = stream.Read(buffer, 0, buffer.Length);
var spaceLeftInBuffer = buffer.Length - bytesRead;
while (spaceLeftInBuffer == 0)
{
// Might be more to read. Expand the buffer.
var newBuffer = new byte[buffer.Length * 2];
spaceLeftInBuffer = buffer.Length;
var totalBytesRead = buffer.Length;
Array.Copy(buffer, 0, newBuffer, 0, totalBytesRead);
buffer = newBuffer;
bytesRead = stream.Read(buffer, totalBytesRead, buffer.Length - totalBytesRead);
spaceLeftInBuffer -= bytesRead;
}
utf8Text = new ReadOnlySpan<byte>(buffer);
NormalizeTextToUTF8(ref utf8Text);
}
static void NormalizeTextToUTF8(ref ReadOnlySpan<byte> text)
{
if (text.Length >= 1)
{
switch (text[0])
{
case 0xEF:
// Possibly start of UTF8 BOM.
if (text.Length >= 3 && text[1] == 0xBB && text[2] == 0xBF)
{
// UTF8 BOM. Step over the UTF8 BOM.
text = text.Slice(3, text.Length - 3);
}
break;
}
}
}
The best I can tell, when loading UTF-8 files with:
var filePicker = new FileOpenPicker{};
StorageFile? file = await filePicker.PickSingleFileAsync();
The BOM has already been eaten by a function before this is called. The beginning of the buffer is the start of the "{"JSON.
Simplified version:
static void ReadStreamToUTF8(Stream stream, out ReadOnlySpan<byte> utf8Text)
{
// This buffer size is chosen to be about 50% larger than the average file size in our corpus, so most of the time
var buffer = new byte[stream.Length];
var bytesRead = stream.Read(buffer, 0, buffer.Length);
utf8Text = new ReadOnlySpan<byte>(buffer);
NormalizeTextToUTF8(ref utf8Text);
}
- Lingua principale
- C#
- Stelle
- 723
- Fork
- 79
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di CommunityToolkit/Lottie-Windows
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
CommunityToolkit/Lottie-Windows#582 · 1 reazione ·
-
file:// uris not supportedAperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
-
Please update to .NET 9Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
Tutte le issue di CommunityToolkit/Lottie-Windows
Issue simili
-
area: core bug help wanted ready
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
ZaidX88/sluice#265 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
area: remote bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Install a C# EnvironmentAperta📅 Sprint 4 Module-Tools Setup Submit:None 🦔 Size Tiny
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
CodeYourFuture/Module-Tools#712 ·
-
:watch: Not Triaged dotnet-fundamentals/svc
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
A: Mapping P3: Standard T: New Feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
space-wizards/space-station-14#46878 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno