C#

[C#]URL 인코딩/디코딩 하기

ㅋㅋ! 2024. 12. 26. 14:09

1. 참조추가

 

2. 인코딩/디코딩

using System;
using System.Web;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = "한글최고";
            string encodedStr = HttpUtility.UrlEncode(str); //인코딩
            string decodedStr = HttpUtility.UrlDecode(encodedStr); //디코딩
            
            Console.WriteLine("인코딩: "+ encodedStr);
            Console.WriteLine("디코딩: " + decodedStr);
            
            Console.ReadLine();

        }
    }
}