I've a task to convert a base64 string to image in asp.net c#, I'm using the following code,
private static bool SaveImage(string path, string link, string name)
{
bool result = true;
if (link.StartsWith("data:image/jpeg;base64,"))
{
try
{
string intImg = path + "/" + name + ".jpg";
System.Drawing.Image bmpFromString = Base64StringToBitmap(link.Replace("data:image/jpeg;base64,",""));
bmpFromString.Save(intImg, ImageFormat.Jpeg);
result = true;
}
catch (Exception)
{
result = false;
}
}
return result;
}
public static System.Drawing.Image Base64StringToBitmap(string base64String)
{
System.Drawing.Image bmpReturn = null;
//string converted = base64String.Replace('-', '+');
//converted = converted.Replace('_', '/');
byte[] byteBuffer = Convert.FromBase64String(base64String);
using (MemoryStream memoryStream = new MemoryStream(byteBuffer))
{
//finalImage = System.Drawing.Image.FromStream(ms);
memoryStream.Position = 0;
bmpReturn = System.Drawing.Image.FromStream(memoryStream);
memoryStream.Close();
byteBuffer = null;
}
return bmpReturn;
}
this is the base64 string
data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBwgHBgkIBwgKCgkLDRYPDQwMDRsUFRAWIB0iIiAdHx8kKDQsJCYxJx8fLT0tMTU3Ojo6Iys/RD84QzQ5OjcBCgoKDQwNGg8PGjclHyU3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3N//AABEIAGQAZAMBIgACEQEDEQH/xAAbAAABBQEBAAAAAAAAAAAAAAAEAAMFBgcBAv/EADsQAAIBAwMBBQYCCQMFAAAAAAECAwAEEQUSITEGEyJBUQcUYXGBkaHRFSMyQoKxwfDxUmKiJTOSsuH/xAAaAQACAwEBAAAAAAAAAAAAAAAEBQECAwYA/8QAKhEAAgICAQMCBgIDAAAAAAAAAAECAwQREhMhMQVRIjIzQXGBkdEUNEL/2gAMAwEAAhEDEQA/ANI4qr6p7Q+zmm3DW8l1LLIhw3cwllH16H6Zp32g3U9n2XuDayd3JLJHDuzjAZgD+VRWndlOyfdbb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wB5rJLU5tWRsFhlSfTHH9K1lrl2eWRcbIkbcCcEn0H9+YrH7CeO5FxJG26IzSFD0ypY4NNvSOXQSYJmrWiPtzIJn24XDZzgbjRjM+MFiTjNCSJJ7y/dsxY/ugAgfHNPNujjPeSF2xjkAfypsLwe4PeNgnPFBWIxdO2VyFx145/xRa9WJ8hUdYNv71h8P5V5HmHvMQx5rtMY9RSqxAE9xG3SRfvTMrofMGuGNE4GDTckgAwAM1Qk8I7KCodlU8kDzrYfY1CP0JcTjrJcNn44AH51jgOa2z2Prt7LKcdZXP8AyP5Us9WesV/lBeJ3t/Rd7qNJ4WRwGBGMGs1vobjsvqErwq7WknIVTwp+VaS5ySPKofWbKO7hKsBnyNc3i5DonteBxFdtMpuodotTvLJksFAZ03K279psdOvT+oJ44xTOx8ostcSHUI2eJAQYH4G7IHIPHn51ebux9yjznndgVnWuFo9dnlQ4IkDA/wAK10mHkdbaS0hfmRUZRkXrtjqMFzaWrW1uYdsu3gKOCpOMDp0/lVVd9wqPN7PKipKwAjHHGc/j/eaF/Sko47pPqTTCtOMdMCukpz2iXVS47tThn8IPxPFRlrFLZyyRTjbztDHgEgdM/Ig09pd7JcajAjhUXJOEB5ODT3aCaOWzjMR6yhzxjOVOD+FVdklYo67FVBODewaSaTd4FJHqKVQ+cUq3MdhJNeFjDrKTnwx7h8812lVS4yv7Nbl7KAB2Rgx/rf8A9jSpUq9Y/wBf9oLwvqFvfzoC4J2/WlSrlV5HCKt2xUPp4U/6g3HqDms11OJV1CaPJYdcnrzXKVdP6T9P+RZnfMBL/wBon5igW/bNKlTgAJbs7GrXLMeqbSD88
The error message is,
Error Message The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters. "
I can't understand what is wrong with this method, would somebody correct me if i'm wrong.
The base64 string you have is not the correct length. Base64 strings should be in blocks of four characters, but you have 4657 characters, or 1164.25 blocks.
Conclusion: You've mistakenly doubled the last 8 in your string. Removing this, you get an image of three people on a yellow background, with a small gray border on the bottom.
You can use:
user.Image.Replace(#"data:image/jpeg;base64,", "");
Related
I'm working on receipt application on c#. I have receipt example with english and arabic words as in below.
I have json text and i try convert that json text to hex and sent as hex format via socket message.
My problem is i try to convert text to Hex i cannot convert successfully. Here is how i convert text to Hex
string hexOutput = "";
byte[] ba = Encoding.Default.GetBytes(output);
hexOutput = BitConverter.ToString(ba);
hexOutput = hexOutput.Replace("-", "");
Here my json example
"PaymentReceipt":[
{
"DocumentQualifier":"CustomerReceipt",
"OutputContent":{
"OutputFormat":"Text",
"OutputText":[
{
"Text":"------------------------------------------------------------"
},
{
"Text":"XXXXXXXXXX2345"
},
{
"Text":"Purchase Amount مبلغ الشراء"
},
{
"Text":"5.00"
},
{
"Text":""
},
{
"Text":"Thanks for your visit شكرا لزيارتكم"
}
]
What can i do for correctly convert text to HEX?
UTF-8 is the most widely used encoding on the web. Check Usage of character encodings broken down by ranking
Code
HexManager static class contains helper extension methods to convert from/to hex.
using System;
using System.Text;
public static class HexManager
{
public static String ToHex(this byte[] data)
{
StringBuilder ret = new StringBuilder(String.Empty);
foreach (byte Value in data)
{
ret.Append(Value.ToString("x2"));
}
return ret.ToString();
}
public static byte[] FromHex(this string data)
{
int Pair = data.Length % 2;
byte[] ret = new byte[data.Length / 2];
if (Pair == 0)
{
for (int i = 0; i < data.Length / 2; i++)
{
ret[i] = Convert.ToByte(data.Substring(i * 2, 2), 16);
}
}
else
{
throw new SystemException("Invalid hex string.");
}
return ret;
}
public static byte[] ToByteArray(this string data)
{
return Encoding.UTF8.GetBytes(data);
}
public static string ToStr(this byte[] data)
{
return Encoding.UTF8.GetString(data);
}
}
public class Example
{
public static void Main()
{
Console.OutputEncoding = System.Text.Encoding.UTF8; //Use Windows Terminal for correct output of UTF-8. No problem on Linux or MacOS Default is UTF-8.
string data = "Purchase Amount مبلغ الشراء";
Console.WriteLine("Original: " + data);
data = data.ToByteArray().ToHex();
Console.WriteLine("Encoded: " + data);
data = data.FromHex().ToStr();
Console.WriteLine("Decoded: " + data);
Console.WriteLine();
Console.WriteLine();
data = "Thanks for your visit شكرا لزيارتكم";
Console.WriteLine("Original: " + data);
data = data.ToByteArray().ToHex();
Console.WriteLine("Encoded: " + data);
data = data.FromHex().ToStr();
Console.WriteLine("Decoded: " + data);
Console.ReadKey();
}
}
Output
On Windows. In console for correct output(arabic codepoints) using UTF-8, I recomend install Windows Terminal.
run wt.exe (Windows terminal)
Inside Windows terminal, run the program.
Magic.
On Linux or MacOS no problem with UTF-8.
PS C:\Users\Megam\source\repos\ConsoleApplication1\ConsoleAppCs\bin\Debug\net5.0> .\ConsoleAppCs.exe
Original: Purchase Amount مبلغ الشراء
Encoded: 507572636861736520416d6f756e742020202020202020202020202020202020202020d985d8a8d984d8ba20d8a7d984d8b4d8b1d8a7d8a1
Decoded: Purchase Amount مبلغ الشراء
Original: Thanks for your visit شكرا لزيارتكم
Encoded: 5468616e6b7320666f7220796f757220766973697420202020202020202020202020d8b4d983d8b1d8a720d984d8b2d98ad8a7d8b1d8aad983d985
Decoded: Thanks for your visit شكرا لزيارتكم
Arabic characters is lies on UTF 8 characters, and for this you initially have to convert it as byte array like this
byte[] bytes = Encoding.UTF8.GetBytes(output);
After that convert it into base64 string or any string you need to convert.
For converting to base64 string
string base64Str = Convert.ToBase64String(bytes);
For getting original bytes from base64 string
byte originalByte = Convert.FromBase64String(base64Str);
For getting UTF8 original output from byte array
string originalResult = Encoding.UTF8.GetString(bytes);
In one line you can get base64 string and revert back as follows
Encode
string encodedStr = Convert.ToBase64String(Encoding.UTF8.GetBytes(output));
Decode
string OriginalString = Encoding.UTF8.GetString(Convert.FromBase64String(encodedStr));
How do you convert an image from a path on the user's computer to a base64 string in C#?
For example, I have the path to the image (in the format C:/image/1.gif) and would like to have a data URI like data:image/gif;base64,/9j/4AAQSkZJRgABAgEAYABgAAD.. representing the 1.gif image returned.
Try this
using (Image image = Image.FromFile(Path))
{
using (MemoryStream m = new MemoryStream())
{
image.Save(m, image.RawFormat);
byte[] imageBytes = m.ToArray();
// Convert byte[] to Base64 String
string base64String = Convert.ToBase64String(imageBytes);
return base64String;
}
}
Get the byte array (byte[]) representation of the image, then use Convert.ToBase64String(), st. like this:
byte[] imageArray = System.IO.File.ReadAllBytes(#"image file path");
string base64ImageRepresentation = Convert.ToBase64String(imageArray);
To convert a base64 image back to a System.Drawing.Image:
var img = Image.FromStream(new MemoryStream(Convert.FromBase64String(base64String)));
Since most of us like oneliners:
Convert.ToBase64String(File.ReadAllBytes(imageFilepath));
If you need it as Base64 byte array:
Encoding.ASCII.GetBytes(Convert.ToBase64String(File.ReadAllBytes(imageFilepath)));
This is the class I wrote for this purpose:
public class Base64Image
{
public static Base64Image Parse(string base64Content)
{
if (string.IsNullOrEmpty(base64Content))
{
throw new ArgumentNullException(nameof(base64Content));
}
int indexOfSemiColon = base64Content.IndexOf(";", StringComparison.OrdinalIgnoreCase);
string dataLabel = base64Content.Substring(0, indexOfSemiColon);
string contentType = dataLabel.Split(':').Last();
var startIndex = base64Content.IndexOf("base64,", StringComparison.OrdinalIgnoreCase) + 7;
var fileContents = base64Content.Substring(startIndex);
var bytes = Convert.FromBase64String(fileContents);
return new Base64Image
{
ContentType = contentType,
FileContents = bytes
};
}
public string ContentType { get; set; }
public byte[] FileContents { get; set; }
public override string ToString()
{
return $"data:{ContentType};base64,{Convert.ToBase64String(FileContents)}";
}
}
var base64Img = new Base64Image {
FileContents = File.ReadAllBytes("Path to image"),
ContentType="image/png"
};
string base64EncodedImg = base64Img.ToString();
You can easily pass the path of the image to retrieve the base64 string
public static string ImageToBase64(string _imagePath)
{
string _base64String = null;
using (System.Drawing.Image _image = System.Drawing.Image.FromFile(_imagePath))
{
using (MemoryStream _mStream = new MemoryStream())
{
_image.Save(_mStream, _image.RawFormat);
byte[] _imageBytes = _mStream.ToArray();
_base64String = Convert.ToBase64String(_imageBytes);
return "data:image/jpg;base64," + _base64String;
}
}
}
Hope this will help.
You can use Server.Map path to give relative path and then you can either create image using base64 conversion or you can just add base64 string to image src.
byte[] imageArray = System.IO.File.ReadAllBytes(Server.MapPath("~/Images/Upload_Image.png"));
string base64ImageRepresentation = Convert.ToBase64String(imageArray);
This code works well with me on DotNet Core 6
using (Image image = Image.FromFile(path))
{
using (MemoryStream m = new MemoryStream())
{
image.Save(m, ImageFormat.Jpeg);
byte[] imageBytes = m.ToArray();
// Convert byte[] to Base64 String
string base64String = Convert.ToBase64String(imageBytes);
// In my case I didn't find the part "data:image/png;base64,", so I added.
return $"data:image/png;base64,{base64String}";
}
}
That way it's simpler, where you pass the image and then pass the format.
private static string ImageToBase64(Image image)
{
var imageStream = new MemoryStream();
try
{
image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Bmp);
imageStream.Position = 0;
var imageBytes = imageStream.ToArray();
var ImageBase64 = Convert.ToBase64String(imageBytes);
return ImageBase64;
}
catch (Exception ex)
{
return "Error converting image to base64!";
}
finally
{
imageStream.Dispose;
}
}
Based on top voted answer, updated for C# 8. Following can be used out of the box. Added explicit System.Drawing before Image as one might be using that class from other namespace defaultly.
public static string ImagePathToBase64(string path)
{
using System.Drawing.Image image = System.Drawing.Image.FromFile(path);
using MemoryStream m = new MemoryStream();
image.Save(m, image.RawFormat);
byte[] imageBytes = m.ToArray();
tring base64String = Convert.ToBase64String(imageBytes);
return base64String;
}
The following piece of code works for me:
string image_path="physical path of your image";
byte[] byes_array = System.IO.File.ReadAllBytes(Server.MapPath(image_path));
string base64String = Convert.ToBase64String(byes_array);
The reverse of this for the googlers arriving here (there is no SO quesion/answer to that)
public static byte[] BytesFromBase64ImageString(string imageData)
{
var trunc = imageData.Split(',')[1];
var padded = trunc.PadRight(trunc.Length + (4 - trunc.Length % 4) % 4, '=');
return Convert.FromBase64String(padded);
}
Something like that
Function imgTo64(ByVal thePath As String) As String
Dim img As System.Drawing.Image = System.Drawing.Image.FromFile(thePath)
Dim m As IO.MemoryStream = New IO.MemoryStream()
img.Save(m, img.RawFormat)
Dim imageBytes As Byte() = m.ToArray
img.Dispose()
Dim str64 = Convert.ToBase64String(imageBytes)
Return str64
End Function
I want to save base64 image to a folder in application, but I have a problem in code. it gives an error as below,
Message = "Invalid length for a Base-64 char array or string."
In my code;
public static string UpdateUser(int refuser, string name, string surname,string base64)
{
string result = "FAILED";
var photo = "";
if (base64!=null && base64!="")
{
string mediaPath = Extend.GetXmlConfigParameter("media", "path")+"User\\";
string mediaName = Guid.NewGuid().ToString();
base64 = base64.Replace("data:image/png;base64,", "");
base64 = base64.Replace("data:image/jpg;base64,", "");
base64 = base64.Replace("data:image/gif;base64,", "");
base64 = base64.Replace("data:image/jpeg;base64,", "");
string filePath = mediaPath + mediaName + ".png";
try
{
byte[] bytes = Convert.FromBase64String(base64);
Image image;
using (MemoryStream ms = new MemoryStream(bytes))
{
image = Image.FromStream(ms);
}
image.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
//File.WriteAllBytes(filePath, Convert.FromBase64String(base64));
photo = mediaName + ".png";
}
catch(Exception ex)
{
Logger.LogError(ex.Message, ex.StackTrace);
return result;
}
}
try
{
DataSet ds = Database.GetDataSet(con, Database.CreateSpQuery("mobile_user_update ",
new List<object> {
refuser,
name,
surname,
photo
}));
if (!Database.IsDataSetValid(ds))
return null;
result = Database.GetString(ds.Tables[0].Rows[0]["Result"]);
}
catch (Exception ex)
{
Logger.LogError(ex.Message, ex.StackTrace);
}
return result;
}
when i try to convert to byte array with below step in code
byte[] bytes = Convert.FromBase64String(base64);
I take this error. my example base64 string is
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMEAAAEFCAMAAABtknO4AAABhlBMVEX////oTD3m5uZMS01PTU8AAADy8vIgICA4OzYPM0egoI7/zMnoSzza29o2Nzb6+vpGRUdBQEIwMDGFhYbIycmxsbLp6enoRzfi4uLv7+/nQzLnRTT0//+bmYnV1dXxTj6oqJjAwMAXFxfJQTTnPiyzs7P98vGzOi+9uq7/0s/mIwvW8/T73tw6OjovLS/ZRzndzMl4d3hZWFrmNCIvMy31sKqWlZb/UDsREREAL0dkZGQAITv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q90GR5PLiKxuA1FdrE8SM7dEHDz7/ii7dOYZs93MHUw8e/PuarzXLt5zPPvj882aY34K2PSX0By7+AVNrKiVZ98Pg8Qfryuy3TVzzKw+W1iBg6eXnH3yufzSG3cRlPAA8iK+LXJpLIoMQwvkGrgCkewFoLBJ59p8Q/cxO6JV8KemFIGC9+cbEZTwGNB375JNPP/3Emz795LNfJVPLH2rdkUPiOssI0vVffLaCfUyf/arRWJJB0PrWjUldYqXe/Ww9AADhF6200wGn63c3Oas2VkD22uh+shEAgPDZp4s6PCOB2U+eBt6XFQbJnRYPZqXPQepdbzU/3cw+AfGLLjrXnhJazdLHSQBWUkIt64h+CcZ2pQm7CDz32We//GWunL3597eFRhy8aSz/AjkAAAAcSURBVCAK3ejPABZIn7oIv4rcKgsvG7itpPH/APV4xrQzYxA1AAAAAElFTkSuQmCC
How can I solve this problem.
Thanks in advance.
It looks that you getting this base64 string through url. If so, you should encode it , before it send to the client.
HttpUtility.UrlEncode(base64string)
I have a c# code which takes the encrypted encoded string of an attachment in infopath and decrypts it. This is the code below:
private int fileSize;
private int attachmentNameLength;
private string attachmentName;
private byte[] decodedAttachment;
/// <summary>
/// Accepts the Base64 encoded string
/// that is the attachment.
/// </summary>
public InfoPathAttachmentDecoder(string theBase64EncodedString)
{
**byte[] theData = Convert.FromBase64String(theBase64EncodedString);** //This line throws a System.FormatException: Invalid length for a Base-64 char array or string.
using (MemoryStream ms = new MemoryStream(theData))
{
BinaryReader theReader = new BinaryReader(ms);
DecodeAttachment(theReader);
}
}
private void DecodeAttachment(BinaryReader theReader)
{
//Position the reader to obtain the file size.
byte[] headerData = new byte[FIXED_HEADER];
headerData = theReader.ReadBytes(headerData.Length);
fileSize = (int)theReader.ReadUInt32();
attachmentNameLength = (int)theReader.ReadUInt32() * 2;
byte[] fileNameBytes = theReader.ReadBytes(attachmentNameLength);
//InfoPath uses UTF8 encoding.
Encoding enc = Encoding.Unicode;
attachmentName = enc.GetString(fileNameBytes, 0, attachmentNameLength - 2);
decodedAttachment = theReader.ReadBytes(fileSize);
}
public void SaveAttachment(string saveLocation)
{
string fullFileName = saveLocation;
if (!fullFileName.EndsWith(Path.DirectorySeparatorChar.ToString()))
{
fullFileName += Path.DirectorySeparatorChar;
}
fullFileName += attachmentName;
if (File.Exists(fullFileName))
File.Delete(fullFileName);
FileStream fs = new FileStream(fullFileName, FileMode.CreateNew);
BinaryWriter bw = new BinaryWriter(fs);
bw.Write(decodedAttachment);
bw.Close();
fs.Close();
}
public string Filename
{
get { return attachmentName; }
}
public byte[] DecodedAttachment
{
get { return decodedAttachment; }
}
}
The line byte[] theData = Convert.FromBase64String(theBase64EncodedString); throws a system format exception invalid length for a base 64 array or string.
What you have is not Base64 encoded and seems to be compromized of tqo sections.
The provided "Base64 data:
x0lGQRQAAAABAAAAAAAAAH8IAAALAAAAdABlAHMAdAAwADEALgB0AHgAdAAAAHVzaW5nIFN5c3RlbTsNCnVzaW5nIFN5c3RlbS5Db2xsZWN0aW9ucy5HZW5lcmljOw0KdXNpbmcgU3lzdGVtLkxpbnE7DQp1c2luZyBTeXN0ZW0uV2ViOw0KdXNpbmcgU3lzdGVtLldlYi5NdmM7DQoNCm5hbWVzcGFjZSBNb3ZpZXNBcHAuQ29udHJvbGxlcnM
This is not encrypted data due to repeated characters.
If you look at the hex values of the data you will see:
78306c4751525141414141424141414141414141414838494141414c414141416441426c41484d4164414177414445414c6742304148674164414141e2808ce2808b4148567a6157356e49464e356333526c6254734ee2808ce2808b436e567a6157356e49464e356333526c62533544e2808ce2808b623278735a574e3061573975637935485a57356ce2808ce2808b636d6c6a4f77304b64584e70626d636755336c7ae2808ce2808b644756744c6b7870626e45374451703163326c75e2808ce2808b5a79425465584e305a573075563256694f77304be2808ce2808b64584e70626d636755336c7a644756744c6c646ce2808ce2808b5969354e646d4d3744516f4e436d35686257567ae2808ce2808b6347466a5a53424e62335a705a584e4263484175e2808ce2808b5132397564484a766247786c636e4d
Note that there are characters out of the Base64 character set such as 0xe2, 0x80, 0x8c, 0xe2, 0x80, 0x8b.
Additionaly there seem to be two parts, there is an initial section of 60 byte that does seem to be Base64. That section Base64 decoded to hex is:
EFCDF4E9CE3BE75E76E75E35E35E35E35E36E35E35E35E35E35E35E35E35E35E3CDFCE3DE35E35E35E1CE35E35E35E35EB8E35E36E9CE35E3CE1DE35EB8E35E35EFBE35E38E39E35E1CEBBE36DF4E35E3CEBBE35EB8E35E35E35
How can I convert a Unicode value to its equivalent string?
For example, I have "రమెశ్", and I need a function that accepts this Unicode value and returns a string.
I was looking at the System.Text.Encoding.Convert() function, but that does not take in a Unicode value; it takes two encodings and a byte array.
I bascially have a byte array that I need to save in a string field and then come back later and convert the string first back to a byte array.
So I use ByteConverter.GetString(byteArray) to save the byte array to a string, but I can't get it back to a byte array.
Use .ToString();:
this.Text = ((char)0x00D7).ToString();
Try the following:
byte[] bytes = ...;
string convertedUtf8 = Encoding.UTF8.GetString(bytes);
string convertedUtf16 = Encoding.Unicode.GetString(bytes); // For UTF-16
The other way around is using `GetBytes():
byte[] bytesUtf8 = Encoding.UTF8.GetBytes(convertedUtf8);
byte[] bytesUtf16 = Encoding.Unicode.GetBytes(convertedUtf16);
In the Encoding class, there are more variants if you need them.
To convert a string to a Unicode string, do it like this: very simple... note the BytesToString function which avoids using any inbuilt conversion stuff. Fast, too.
private string BytesToString(byte[] Bytes)
{
MemoryStream MS = new MemoryStream(Bytes);
StreamReader SR = new StreamReader(MS);
string S = SR.ReadToEnd();
SR.Close();
return S;
}
private string ToUnicode(string S)
{
return BytesToString(new UnicodeEncoding().GetBytes(S));
}
UTF8Encoding Class
UTF8Encoding uni = new UTF8Encoding();
Console.WriteLine( uni.GetString(new byte[] { 1, 2 }));
There are different types of encoding. You can try some of them to see if your bytestream get converted correctly:
System.Text.ASCIIEncoding encodingASCII = new System.Text.ASCIIEncoding();
System.Text.UTF8Encoding encodingUTF8 = new System.Text.UTF8Encoding();
System.Text.UnicodeEncoding encodingUNICODE = new System.Text.UnicodeEncoding();
var ascii = string.Format("{0}: {1}", encodingASCII.ToString(), encodingASCII.GetString(textBytesASCII));
var utf = string.Format("{0}: {1}", encodingUTF8.ToString(), encodingUTF8.GetString(textBytesUTF8));
var unicode = string.Format("{0}: {1}", encodingUNICODE.ToString(), encodingUNICODE.GetString(textBytesCyrillic));
Have a look here as well: http://george2giga.com/2010/10/08/c-text-encoding-and-transcoding/.
var ascii = $"{new ASCIIEncoding().ToString()}: {((ASCIIEncoding)new ASCIIEncoding()).GetString(textBytesASCII)}";
var utf = $"{new UTF8Encoding().ToString()}: {((UTF8Encoding)new UTF8Encoding()).GetString(textBytesUTF8)}";
var unicode = $"{new UnicodeEncoding().ToString()}: {((UnicodeEncoding)new UnicodeEncoding()).GetString(textBytesCyrillic)}";
Wrote a cycle for converting unicode symbols in string to UTF8 letters:
string stringWithUnicodeSymbols = #"{""id"": 10440119, ""photo"": 10945418, ""first_name"": ""\u0415\u0432\u0433\u0435\u043d\u0438\u0439""}";
var splitted = Regex.Split(stringWithUnicodeSymbols, #"\\u([a-fA-F\d]{4})");
string outString = "";
foreach (var s in splitted)
{
try
{
if (s.Length == 4)
{
var decoded = ((char) Convert.ToUInt16(s, 16)).ToString();
outString += decoded;
}
else
{
outString += s;
}
}
catch (Exception e)
{
outString += s;
}
}