Convert UTF-8 String Classic ASP SQL Database

So, I had a problem with correctly setting French characters. Basically, I have a form that sends data to an SQL database. Then, on another page, data from this database is extracted and displayed to the user. But the data (rows) were displayed with more strange corrupt characters, because the input to the form on another page was in French. I overcame this problem using the following function, which converts the string to the correct encoding. HOWEVER, obviously, the best solution is to convert FIRST and then send it to the database. Now here is the code to convert the string received from the database to the corresponding encoding:

Function ConvertFromUTF8(sIn)

    Dim oIn: Set oIn = CreateObject("ADODB.Stream")

    oIn.Open
    oIn.CharSet = "WIndows-1252"
    oIn.WriteText sIn
    oIn.Position = 0
    oIn.CharSet = "UTF-8"
    ConvertFromUTF8 = oIn.ReadText
    oIn.Close

End Function

: ASP - UTF-8 UCS-2?

: , , , , ?

Tried Paul:

, 1 2. 1 , , . 2. Paul, ConvertFromUTF8 ( ). Page 1.

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>

:

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

: (

: !, ! , , "CodePage = 65001" ( ), .

+3
2

,

, , ;

: - ( ).

  • , UTF-8 encoding double, , IDE Windows-1252.
  • ​​ , , , .

    - page_encoding.asp

    <%@Language="VBScript" CodePage = 65001 %>
    <% 
      Response.CharSet = "UTF-8"
      Response.CodePage = 65001
    %>
    

    ASP ( )

    <!-- #include virtual="/config/page_encoding.asp" -->
    

    Response.Charset = "UTF-8" ;charset HTTP content-type. Response.CodePage = 65001 ASP UTF-8.

  • UTF-8 ( ).

, , , Windows-1252, UTF-8, .

+7

- - , . asp :

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>

ASP ( ) UTF-8. , 2 . , , 1 char 2 nchar, . . , , :

áäÇçéčëíďńóöçÖöÚü

"", "Unicode"... Unicode , 1252, .

+3

All Articles