Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

C#: Convertir un tableau d’octet UTF-16 en String


{filelink=19655}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace Mesexemples
{
    class ByteArrayUnicodeToString
    {
        static void Main(string[] args)
        {
            byte[] bytes = new Byte[args[0].Length];
            Console.WriteLine("Octet Unicode en String: " + UTF16ByteArrayToString(bytes));
            Console.ReadLine();
        }
        public static string UTF16ByteArrayToString(byte[] characters)
        {
            UnicodeEncoding encoding = new UnicodeEncoding();
            string resultString = encoding.GetString(characters);
 
            return (resultString);
        }
    }
}

No comments yet.

Leave a Comment