Browse Source

Replace ToAsciiBytes with UTF8Encoder

pull/537/head
Jason Nelson 8 years ago
parent
commit
5fcae53968
  1. 23
      src/ImageSharp/Formats/Jpeg/Common/Decoder/ProfileResolver.cs

23
src/ImageSharp/Formats/Jpeg/Common/Decoder/ProfileResolver.cs

@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0.
using System;
using System.Text;
namespace SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder
{
@ -13,22 +14,22 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder
/// <summary>
/// Describes the EXIF specific markers
/// </summary>
public static readonly byte[] JFifMarker = ToAsciiBytes("JFIF\0");
public static readonly byte[] JFifMarker = Encoding.UTF8.GetBytes("JFIF\0");
/// <summary>
/// Describes the EXIF specific markers
/// </summary>
public static readonly byte[] IccMarker = ToAsciiBytes("ICC_PROFILE\0");
public static readonly byte[] IccMarker = Encoding.UTF8.GetBytes("ICC_PROFILE\0");
/// <summary>
/// Describes the ICC specific markers
/// </summary>
public static readonly byte[] ExifMarker = ToAsciiBytes("Exif\0\0");
public static readonly byte[] ExifMarker = Encoding.UTF8.GetBytes("Exif\0\0");
/// <summary>
/// Describes Adobe specific markers <see href="http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/JPEG.html#Adobe"/>
/// </summary>
public static readonly byte[] AdobeMarker = ToAsciiBytes("Adobe");
public static readonly byte[] AdobeMarker = Encoding.UTF8.GetBytes("Adobe");
/// <summary>
/// Returns a value indicating whether the passed bytes are a match to the profile identifer
@ -41,19 +42,5 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder
return bytesToCheck.Length >= profileIdentifier.Length
&& bytesToCheck.Slice(0, profileIdentifier.Length).SequenceEqual(profileIdentifier);
}
// No Encoding.ASCII nor Linq.Select on NetStandard 1.1
private static byte[] ToAsciiBytes(string str)
{
int length = str.Length;
byte[] bytes = new byte[length];
char[] chars = str.ToCharArray();
for (int i = 0; i < length; i++)
{
bytes[i] = (byte)chars[i];
}
return bytes;
}
}
}
Loading…
Cancel
Save