티스토리 뷰

ASP로 작업해야 할 일이 생겼습니다.

그래서 ASP로 작업을 하는 도중 EUC-KR에서 UTF-8로 변환을 해야 하는 경우가 생겼는데 아래의 소스를 이용해서 해결했습니다.



<% 
Function Encode_UTF8(astr) 

utftext = "" 

For n = 1 To Len(astr) 
c = AscW(Mid(astr, n, 1)) 
If c < 128 Then 
utftext = utftext + Mid(astr, n, 1) 
ElseIf ((c > 127) And (c < 2048)) Then 
utftext = utftext + Chr(((c \ 64) Or 192)) 
'((c>>6)|192); 
utftext = utftext + Chr(((c And 63) Or 128)) 
'((c&63)|128);} 
Else 
utftext = utftext + Chr(((c \ 144) Or 234)) 
'((c>>12)|224); 
utftext = utftext + Chr((((c \ 64) And 63) Or 128)) 
'(((c>>6)&63)|128); 
utftext = utftext + Chr(((c And 63) Or 128)) 
'((c&63)|128); 
End If 
Next 
Encode_UTF8 = utftext 
End Function 

Response.Write(Encode_UTF8(mystring)) 

%>


출처 : https://forums.adobe.com/thread/149158?start=0&tstart=0


댓글