Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

convert asp string to UTF-8?

1 view
Skip to first unread message

Michealnl

unread,
May 8, 2007, 5:11:33 AM5/8/07
to
Hello,

I have a plain text file with special charset like ' ???'
I finally got it to work. But now i am trying to use a asp file to write out
the text. But i don't
know how to convert to UTF-8 in ASP.

I have this, but it still does not work:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>TEST</title>
</head>
<%

'set output character set
Response.CharSet = "utf-8"

Response.Write("This is a test ???")

%>
</body>
</html>

Does anyone has knowledge of how this could be done?

Regards,

Micheal.

Raymond Basque

unread,
May 8, 2007, 6:18:08 AM5/8/07
to
Just make sure the asp file is saved with utf-8 encoding.

For example, in Notepad: File-->Save As. Select UTF-8 in the Encoding combo.


pajaroplus

unread,
May 8, 2007, 6:43:37 AM5/8/07
to
i recommend you to use notepad++

Michealnl

unread,
May 10, 2007, 7:39:18 AM5/10/07
to
I found a solution that works for me :)

<%
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))

%>

luciewong

unread,
May 12, 2007, 1:12:03 PM5/12/07
to
hi, I use below in my asps for chinese characters>
<%
'Set codepage to support unicode
Response.Charset = "utf-8"
Session.CodePage = 65001
%>

regards
Luciewong

8loolos

unread,
Jul 22, 2008, 12:56:18 PM7/22/08
to
or use this for asp pages:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
0 new messages