ASP coding issues when using English and Chinese characters

I'm having problems coding Chinese in ASP site. File Formats:

  • translations.txt - UTF-8 (to store my translations)
  • test.asp - UTF-8 - (to display the page)

test.asp reads translations.txt, which contains the following data:

Help|ZH|帮助 
Home|ZH|首页

Test.asp is broken into a channel separator, and if the user contains a cookie with ZH, he displays this translation, otherwise he will simply return to the key value.

Now I tried the following things that did not work:

  • Add meta tag

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

  • Set Response.CharSet = "UTF-8"

  • Set Response.ContentType = "text/html"
  • Set Session.CodePage (and response) as for 65001 (UTF-8)
  • I confirmed that the text in is translations.txtdefinitely in UTF-8 and has a byte character
  • , Unicode UTF-8, gobbledegook.
  • Scripting.OpenTextFile(<file>,<create>,<iomode>,<encoding>) Encoding.

, (ZH):

  • 首页
  • 帮助

:

  • é|-é¡μ
  • å¸®åŠ ©

- Google Chrome, IE 7/8 Firefox 4. . , .

-

HTML, ( , ).

  • 首页
  • é|-é¡μ

.

首页 - ( ) → E9 A6 96 E9 A1 - ( ) → é|-é¡μ

, ?

+3
4

UTF-8, , , ADODB.Stream. , , :

test.txt( UTF-8 ):

首页
帮助

test.vbs

Option Explicit

Const adTypeText = 2
Const adReadLine = -2

Dim stream : Set stream = CreateObject("ADODB.Stream")
stream.Open
stream.Type = adTypeText
stream.Charset = "UTF-8"
stream.LoadFromFile "test.txt"

Do Until stream.EOS
    WScript.Echo stream.ReadText(adReadLine)
Loop

stream.Close
+2

translations.txt, , , UTF-8. , - . . -.

.

0

Scripting.OpenTextFile UTF-8. OEM- Unicode. , , UTF-8 . Unicode .

Unicode ( Windows), :

Dim stream : Set stream = Scripting.OpenTextFile(yourFilePath, 1, false, -1)
0

Just use the script below at the top of the page

Response.CodePage=65001
Response.CharSet="UTF-8"
0
source

All Articles