From 5fcae53968f1ae9242829e2333f7af5b5676cb90 Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Wed, 18 Apr 2018 17:29:33 -0700 Subject: [PATCH] Replace ToAsciiBytes with UTF8Encoder --- .../Jpeg/Common/Decoder/ProfileResolver.cs | 23 ++++--------------- 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/src/ImageSharp/Formats/Jpeg/Common/Decoder/ProfileResolver.cs b/src/ImageSharp/Formats/Jpeg/Common/Decoder/ProfileResolver.cs index 7ea0f9215e..2030ad71b1 100644 --- a/src/ImageSharp/Formats/Jpeg/Common/Decoder/ProfileResolver.cs +++ b/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 /// /// Describes the EXIF specific markers /// - public static readonly byte[] JFifMarker = ToAsciiBytes("JFIF\0"); + public static readonly byte[] JFifMarker = Encoding.UTF8.GetBytes("JFIF\0"); /// /// Describes the EXIF specific markers /// - public static readonly byte[] IccMarker = ToAsciiBytes("ICC_PROFILE\0"); + public static readonly byte[] IccMarker = Encoding.UTF8.GetBytes("ICC_PROFILE\0"); /// /// Describes the ICC specific markers /// - public static readonly byte[] ExifMarker = ToAsciiBytes("Exif\0\0"); + public static readonly byte[] ExifMarker = Encoding.UTF8.GetBytes("Exif\0\0"); /// /// Describes Adobe specific markers /// - public static readonly byte[] AdobeMarker = ToAsciiBytes("Adobe"); + public static readonly byte[] AdobeMarker = Encoding.UTF8.GetBytes("Adobe"); /// /// 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; - } } } \ No newline at end of file