0
convert asp string to UTF-8?

/t5/dreamweaver-discussions/convert-asp-string-to-utf-8/td-p/541384
May 08, 2007
May 08, 2007
Copy link to clipboard
Copied
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.
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.
TOPICS
Code
,
How to
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/dreamweaver-discussions/convert-asp-string-to-utf-8/m-p/541385#M55631
May 08, 2007
May 08, 2007
Copy link to clipboard
Copied
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.
For example, in Notepad: File-->Save As. Select UTF-8 in the Encoding combo.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Explorer
,
/t5/dreamweaver-discussions/convert-asp-string-to-utf-8/m-p/541386#M55632
May 08, 2007
May 08, 2007
Copy link to clipboard
Copied
i recommend you to use notepad++
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

Guest
AUTHOR
/t5/dreamweaver-discussions/convert-asp-string-to-utf-8/m-p/541387#M55633
May 10, 2007
May 10, 2007
Copy link to clipboard
Copied
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))
%>
<%
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))
%>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
New Here
,
/t5/dreamweaver-discussions/convert-asp-string-to-utf-8/m-p/541388#M55634
May 12, 2007
May 12, 2007
Copy link to clipboard
Copied
hi, I use below in my asps for chinese characters>
<%
'Set codepage to support unicode
Response.Charset = "utf-8"
Session.CodePage = 65001
%>
regards
Luciewong
<%
'Set codepage to support unicode
Response.Charset = "utf-8"
Session.CodePage = 65001
%>
regards
Luciewong
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

Guest
AUTHOR
/t5/dreamweaver-discussions/convert-asp-string-to-utf-8/m-p/541389#M55635
Jul 22, 2008
Jul 22, 2008
Copy link to clipboard
Copied
or use this for asp pages:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Explorer
,
LATEST
/t5/dreamweaver-discussions/convert-asp-string-to-utf-8/m-p/541390#M55636
Aug 13, 2017
Aug 13, 2017
Copy link to clipboard
Copied
Obviously a little old thing, but here´s the reference to do it
'const adTypeBinary = 1
'const adSaveCreateOverwrite = 2
'const adModeReadWrite = 3
'Set objStream = server.CreateObject("ADODB.Stream")
'objStream.Open
'objStream.CharSet = "UTF-8"
'objStream.WriteText("write your text")
'objStream.SaveToFile server.mappath(".") & "/your.txt" , adSaveCreateOverWrite
'objStream.Close
(without the remark, certainly)
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

