encoding2 Web에서 획득한 데이터 한글깨짐 현상수정 #로또, #동행복권 회차 데이터 수집을 위해 메인페이지의 html 소스를 바로 Parsing할 생각이다. string sUrl = string.Format(@"https://dhlottery.co.kr/gameResult.do?method=byWin"); Encoding encoding = Encoding.UTF8; byte[] result = encoding.GetBytes(sUrl.ToString()); HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(sUrl); webReq.Method = "GET"; webReq.Timeout = 10000; //10sec using (HttpWebResponse webRes = (HttpWebResponse.. 2021. 4. 20. byte UTF8Encoding시 OOM(OutOfMemory) 오류 발생 서버로부터 수신받은 byte array 데이터를 UTF8로 encoding시 간헐적으로 OOM(OutOfMemory)가 발생한다. 조회성 데이터는 상관없지만 3rd Party 업체로부터 수신받은 응답 데이터에서 저런 경우가 발생할 경우 무척 난감해지는 상황이 발생한다. 대부분 byte array를 string 으로 변환하는 코드는 아래코드가 대부분이다. string sBuffer = Encoding.Default.GetString(byteBuffer); 하지만 MemoryStream을 이용한 방법도 있으므로 사이즈가 큰 데이터는 MemoryStream을 이용한 방법을 사용하는것도 괜찮은듯 싶다. public static string GetStreamEncoding(byte[] inBytes) { usin.. 2021. 1. 29. 이전 1 다음