Classic ASP: How to write unicode string data in classic ASP?

后端 未结 3 664
眼角桃花
眼角桃花 2020-12-05 11:32

How can I show an nvarchar column that stores unicode data (Entered with the zawgyi1 font) in a classic ASP web page?

When I retrieve and write the value to the pag

3条回答
  •  悲哀的现实
    2020-12-05 12:05

    Here's a useful script to batch-convert ASP files from ANSI to UTF-8 encoding:

    
    
    ASP UTF-8 Converter - TFI 13/02/2015
    
    
    <%
    Dim fso, folder, files, NewsFile, sFolder, objFSO, strFileIn, strFileOut
    Set fso = CreateObject("Scripting.FileSystemObject")
    sFolder = "C:\inetpub\wwwroot\sitefolder"
    
    Function ANSItoUTF8( ANSIFile)
       UFT8FileOut=ANSIFile&".utf8" 
       Set oFS    = CreateObject( "Scripting.FileSystemObject" )
       Set oFrom  = CreateObject( "ADODB.Stream" )
       sFFSpec    = oFS.GetAbsolutePathName(ANSIFile)
       Set oTo    = CreateObject( "ADODB.Stream" )
       sTFSpec    = oFS.GetAbsolutePathName(UFT8FileOut)
       oFrom.Type    = 2 'adTypeText
       oFrom.Charset = "Windows-1252"
       oFrom.Open
       oFrom.LoadFromFile sFFSpec
       oTo.Type    = 2 'adTypeText
       oTo.Charset = "utf-8"
       oTo.Open
       oTo.WriteText oFrom.ReadText
       oTo.SaveToFile sTFSpec,2
       oFrom.Close
       oTo.Close
       oFS.DeleteFile sFFSpec
       oFS.MoveFile sTFSpec,sFFSpec
    End Function
    
    ConvertFiles fso.GetFolder(sFolder), True
    
    Function ConvertFiles(objFolder, bRecursive)
        Dim objFile, objSubFolder
        For each objFile in objFolder.Files
            If Ucase(fso.GetExtensionName(objFile)) = "ASP" Then
                ANSItoUTF8 objFile.path
                response.write "• Converted "&fso.GetAbsolutePathName(objFile)&" from ANSI to UTF-8
    " End If Next If bRecursive = true then For each objSubFolder in objFolder.Subfolders ConvertFiles objSubFolder, true Next End If End Function %>

提交回复
热议问题