Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 35 lines (31 sloc) 1.101 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
using System.Text;
using LibGit2Sharp.Core;

namespace LibGit2Sharp
{
    /// <summary>
    /// Provides helper overloads to a <see cref = "Blob" />.
    /// </summary>
    public static class BlobExtensions
    {
        /// <summary>
        /// Gets the blob content decoded as UTF-8.
        /// </summary>
        /// <param name="blob">The blob for which the content will be returned.</param>
        /// <returns>Blob content as UTF-8</returns>
        public static string ContentAsUtf8(this Blob blob)
        {
            Ensure.ArgumentNotNull(blob, "blob");

            return Encoding.UTF8.GetString(blob.Content);
        }

        /// <summary>
        /// Gets the blob content decoded as Unicode.
        /// </summary>
        /// <param name="blob">The blob for which the content will be returned.</param>
        /// <returns>Blob content as unicode.</returns>
        public static string ContentAsUnicode(this Blob blob)
        {
            Ensure.ArgumentNotNull(blob, "blob");

            return Encoding.Unicode.GetString(blob.Content);
        }
    }
}
Something went wrong with that request. Please try again.