Skip to content

Commit

Permalink
cuelist support standard UTF8 character
Browse files Browse the repository at this point in the history
  • Loading branch information
htrs-yangrui committed Dec 8, 2020
1 parent a2cc704 commit 410e0c7
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions NAudio/Wave/WaveStreams/CueList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ public class Cue
public Cue(int position, string label)
{
Position = position;
if (label == null)
{
label = "";
}
Label = Regex.Replace(label, @"[^\u0000-\u00FF]", "");
Label = label??string.Empty;
}
}

Expand Down Expand Up @@ -189,7 +185,7 @@ internal byte[] GetRiffChunks()
var listChunkLength = 12;
for (int i = 0; i < Count; i++)
{
var labelChunkLength = this[i].Label.Length + 1;
var labelChunkLength = Encoding.UTF8.GetBytes(this[i].Label).Length + 1;
listChunkLength += labelChunkLength + labelChunkLength % 2 + 12;
}

Expand Down Expand Up @@ -222,11 +218,12 @@ internal byte[] GetRiffChunks()
writer.Write(adtlTypeId);
for (int cue = 0; cue < Count; cue++)
{
var labelArray = Encoding.UTF8.GetBytes(this[cue].Label);
writer.Write(labelChunkId);
writer.Write(this[cue].Label.Length + 1 + 4);
writer.Write(labelArray.Length + 1 + 4);
writer.Write(cue);
writer.Write(Encoding.UTF8.GetBytes(this[cue].Label.ToCharArray()));
if (this[cue].Label.Length % 2 == 0)
writer.Write(labelArray);
if (labelArray.Length % 2 == 0)
{
writer.Seek(2, SeekOrigin.Current);
}
Expand Down

0 comments on commit 410e0c7

Please sign in to comment.