本文介绍了ASP:我不能去code一些字符从UTF-8到ISO-8859-1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用此功能去code UTF-8:

函数德codeUTF8(S)
  我朦胧
  尺寸C
  昏暗的ñ
  I = 1
  做,而我< = LEN(S)
    C = ASC(MID(S,I,1))
    如果C和放大器;然后H80
      N = 1
      做而I + N<镜片)
        如果(ASC(MID(S,I + N,1))和放大器; HC0)LT;> &安培;然后H80
          做出口
        万一
        N = N + 1
      循环
      如果n = 2和((C和放大器; HE0)=安培; HC0)然后
        C = ASC(MID(S,I + 1,1))+&安培; H40 *(c和&安培; H01)
      其他
        C = 191
      万一
      S =左(S,I-1)+ CHR(C)+中期(S,I + N)
    万一
    I = I + 1
  循环  德codeUTF8 = S
最终功能

但也有一些probles脱code的字符:

In that case

I found some info related with this problem:http://www.i18nqa.com/debug/utf8-debug.html

Do you know any function to decode correctly?

解决方案
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

这篇关于ASP:我不能去code一些字符从UTF-8到ISO-8859-1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 10:03