// EUC-KR
private string EuckrEncoding(string data)
{
System.Text.Encoding euckr = System.Text.Encoding.GetEncoding(51949);
byte[] euckrBytes = euckr.GetBytes(data);
string urlEncodingText = "";
foreach (byte b in euckrBytes)
{
string addText = Convert.ToString(b, 16);
urlEncodingText = urlEncodingText + "%" + addText;
}
return Convert.ToString(urlEncodingText);
}
// UTF-8
private string Utf8Encoding(string data)
{
System.Text.Encoding utf8 = System.Text.Encoding.UTF8;
byte[] utf8Bytes = utf8.GetBytes(data);
string urlEncodingText = "";
foreach (byte b in utf8Bytes)
{
string addText = Convert.ToString(b, 16);
urlEncodingText = urlEncodingText + "%" + addText;
}
return Convert.ToString(urlEncodingText);
}
'C# > Winform' 카테고리의 다른 글
역슬래시 \문자열 디코딩하기 (0) | 2021.02.15 |
---|---|
[C#] List.ForEach 에서 continue 처리 (0) | 2020.12.30 |
[C#] HttpUtility UrlEncode/UrlDecode 처리하기 (%문자열) (0) | 2020.09.08 |
[C#] RGB to HSV, HSV to RGB (0) | 2020.08.27 |
[C#] Dictoinary 의 index 값 가져오기 (1) | 2020.08.19 |