ASP: I can´t decode some character from utf-8 to iso-8859-1

后端 未结 1 637
天涯浪人
天涯浪人 2021-01-22 17:13

I use this function to decode UTF-8:

function DecodeUTF8(s)
  dim i
  dim c
  dim n
  i = 1
  do while i <= len(s)
             


        
1条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-22 17:26

    Public Function DecodeUTF8(s)
      Set stmANSI = Server.CreateObject("ADODB.Stream")
      s = s & ""
      On Error Resume Next
    
      With stmANSI
        .Open
        .Position = 0
        .CharSet = "Windows-1252"
        .WriteText s
        .Position = 0
        .CharSet = "UTF-8"
      End With
    
      DecodeUTF8 = stmANSI.ReadText
      stmANSI.Close
    
      If Err.number <> 0 Then
        lib.logger.error "str.DecodeUTF8( " & s & " ): " & Err.Description
        DecodeUTF8 = s
      End If
      On error Goto 0
    End Function
    

    0 讨论(0)
提交回复
热议问题