FolkerKinzel.Uris 1.0.0-beta.1

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
This is a prerelease version of FolkerKinzel.Uris.
There is a newer version of this package available.
See the version list below for details.
dotnet add package FolkerKinzel.Uris --version 1.0.0-beta.1
NuGet\Install-Package FolkerKinzel.Uris -Version 1.0.0-beta.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FolkerKinzel.Uris" Version="1.0.0-beta.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FolkerKinzel.Uris --version 1.0.0-beta.1
#r "nuget: FolkerKinzel.Uris, 1.0.0-beta.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install FolkerKinzel.Uris as a Cake Addin
#addin nuget:?package=FolkerKinzel.Uris&version=1.0.0-beta.1&prerelease

// Install FolkerKinzel.Uris as a Cake Tool
#tool nuget:?package=FolkerKinzel.Uris&version=1.0.0-beta.1&prerelease

GitHub

Project Reference and Release Notes

The library contains:

  • readonly struct DataUrl: Represents a "data" URL (RFC 2397) that embeds data in-line in a URL. It enables you to retrieve this data and to find automatically an appropriate file type extension for it. A DataUrl can be created automatically from the data to embed. This can be a file, a byte array or a string.

The library makes extensive use of ReadOnlySpan<Char> and ReadOnlyMemory<Char> to build and examine the content of such URIs without having to allocate a lot of temporary Strings.

.

Example:

Creating and parsing a "data" URL:

using System;
using System.Diagnostics;
using System.IO;
using FolkerKinzel.Uris;

namespace Examples
{
    public static class DataUrlExample
    {
        public static void Example()
        {
            string fotoFilePath = CreatePhotoFile();
            string dataUrl = DataUrl.FromFile(fotoFilePath);
            File.Delete(fotoFilePath);

            // Uncomment this, to show the content of the
            // "data" URL in the Microsoft Edge browser.
            // (Make shure to have this browser installed.):
            // ShowPictureInMicrosoftEdge(dataUrl);

            Console.WriteLine(dataUrl);
            Console.WriteLine();

            // Parse the content of the "data" URL:
            var info = DataUrlInfo.Parse(dataUrl);

            Console.WriteLine($"Contains Bytes: {info.ContainsEmbeddedBytes}");
            Console.WriteLine($"Contains Text:  {info.ContainsEmbeddedText}");
            Console.WriteLine($"MIME Type:      {info.MimeType}");
            Console.WriteLine($"File Type Ext.: {info.GetFileTypeExtension()}");
            Console.WriteLine($"Data Encoding:  {info.DataEncoding}");

            if (info.TryGetEmbeddedBytes(out byte[]? bytes))
            {
                Console.WriteLine($"Data Length:    {bytes.Length} Bytes");
            }
        }

        private static string CreatePhotoFile()
        {
            string url = "data:image/jpeg;base64,/9j/4QAYRXhpZgAA ~ 0JFFIH0+uvTs//Z";

            var info = DataUrlInfo.Parse(url);
            string path = Path.Combine(Directory.GetCurrentDirectory(),
                                       Guid.NewGuid().ToString() + info.GetFileTypeExtension());

            if (info.TryGetEmbeddedBytes(out byte[]? bytes))
            {
                File.WriteAllBytes(path, bytes);
            }

            return path;
        }

        private static void ShowPictureInMicrosoftEdge(string dataUrl)
        {
            var process = new Process();
            process.StartInfo.UseShellExecute = true;
            process.StartInfo.FileName = "msedge";
            process.StartInfo.Arguments = dataUrl;
            _ = process.Start();
        }
    }
}

/*
Console Output:

data:image/jpeg;base64,/9j/4QAYRXhpZgAA ~ 0JFFIH0+uvTs//Z

Contains Bytes: True
Contains Text:  False
MIME Type:      image/jpeg
File Type Ext.: .jpg
Data Encoding:  Base64
Data Length:    2472 Bytes
 */

.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
5.2.2 114 3/10/2024
5.2.1 90 3/10/2024
5.2.0 236 11/26/2023
5.1.1 2,158 11/5/2023
5.1.0 137 10/27/2023
5.0.1 916 10/18/2023
5.0.0 149 9/30/2023
4.0.1 133 9/24/2023
4.0.0 159 8/20/2023
4.0.0-beta.1 76 8/11/2023
3.0.0-beta.2 74 8/10/2023
3.0.0-beta.1 75 8/9/2023
2.0.0-beta.1 78 7/24/2023
1.0.0-beta.5 5,520 1/21/2022
1.0.0-beta.4 124 1/3/2022
1.0.0-beta.3 140 9/8/2021
1.0.0-beta.2 125 8/31/2021
1.0.0-beta.1 142 8/30/2021
1.0.0-alpha.1 137 8/9/2021