Converting string to Unicode characters

c#, string, unicode, utf-8

Solution

Try this:

    string input = "nsa";
    var result = input.Select(t => string.Format("U+{0:X4} ", Convert.ToUInt16(t))).ToList();

Or with nicer formatting (C# 6):

    string input = "nsa";
    var result = input.Select(t => $"U+{Convert.ToUInt16(t):X4} ").ToList();

Problem

I'm trying to Convert a string in to a series of unicode characters. for expample : if I have a string that contains "Ñ", the unicode I want would be this "U+00D1". Edit thank you everyone for your time. What I wanted was the hexadecimal representative of the unicode character no the character itself encoded in unicode.

Original source

Related problems